[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Q: foreach my($var) ...



Here's a minor difference I noticed between MacPerl and unix Perl. The following script runs fine in MacPerl, but in Linux perl it complains "Missing $ on loop variable at ./x.pl line 8."

#!/usr/local/bin/perl -w

use strict;

my(@array1) = 0..5;


foreach my $some (@array1) {print "$some\n";}

__END__


Can anyone give some explaination?


Now, ***  by-----the-----waaaay ***, if I do my($some) in the foreach line, perl will complain. (I havn't done much "homework" on this. Probably a stupid question...) What's the proper way? (I always like to add parenthesis even if not needed, but apprantly perl does not work that way...)

Curiously,

 Xah, xah@best.com
 http://www.best.com/~xah/Wallpaper_dir/c0_WallPaper.html
 "Mathematics, when viewed from the right angle, can be as boring as one could imagine."    --Mathematcian's lore



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch