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

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



[Xah, by the way, could you tell your e-mail program to insert proper newlines
in paragraphs?]

Xah Lee <xah@best.com> writes:
>Here's a minor difference I noticed between MacPerl and unix Perl. The followi
ng script runs fine in MacPerl, but in Linux perl it complains "Missing $ on lo
op variable at ./x.pl line 8."

for my $x () was introduced in perl5.004, I would assume that your Linux
installation is still 5.003.

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

The proper way is the one that does not cause the compiler to
complain. Parentheses after my serve to evoke list context, which is usually
right in declarations

my($x,$y) = (1,2);

but wrong in for statements for now.

Matthias

-- 
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "One fine day in my odd past..." -- Pixies, _Planet of Sound_






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