Hi, cbkihong.
An aside.
Quote:
Originally Posted by cbkihong
Perl doesn't have the foreach() loop syntax like that, I think. It looks more like Javascript or PHP than Perl. I guess you should try to quote any error messages if any, and indicate which line the error exists. The segment you posted does not appear to be a correct Perl program.
|
I thought so at first also, so I wrote a short script to see what happened:
Code:
#!/usr/bin/perl
# @(#) perl-basic Template for common usage.
# use warnings;
# use strict;
my($debug);
$debug = 0;
$debug = 1;
my(@a) = qw/ a b c d e /;
my($a) = @a;
foreach my $i ( in $a ) {
print " i is :$i:\n";
}
exit(0);
which produced:
Code:
% ./p1
Can't locate object method "in" via package "a" (perhaps you forgot to load "a"?) at ./p1 line 15.
That seems to be something to do with the OO features of perl, with which I am not sufficiently familiar to be able to provide an explanation. I perused Schwartz'
Intermediate perl, but found nothing on-point so far.
I think we both looked at this and saw a corruption of the
foreach with syntax from some other language. However, almost anything seems to be legal in perl. So, at least from my perspective, I was led to the wrong conclusion by assuming a syntax infraction.
Even if one enables strict and warnings, the same message is produced ... cheers, drl