I have a simple question. I have been using the zoidberg perl shell to get myself familiarized with perl interactively. I like being able to test my stuff on the fly before I flesh out a script. (I am a novice learner.)
My question is, in the shell I can do the following:
@a = `df -h | grep /dev/mapper | cut -c 48-`
for $i (@a) { @b=`ls $i` }
print @b;
However, when I put this in a script in linux:
#!/bin/perl
I see the following error when I run the script:
syntax error at perl_diskstats.perl line 5, near "$i ( "
Execution of perl_diskstats.perl aborted due to compilation errors.
Am I doing something obvious here? What exactly am I doing wrong? I thought the format was..
foreach $var (@array) { codeblock }
... right?