I am getting this message and I'm not sure why. Can someone explain this? Is perl 5.6 complaining that the "my" does not start with a "$" character?
Missing $ on loop variable at /home/chad/bin/tee-err-warn.pl line 40.
Line 40 has a foreach loop.
# find lines with keywords
foreach my $i (@keywords) { ## -- LINE 40 --
if($line =~ m/$i/i) {
# copy found lines to the found lines array
push @found , $line;
}
}
The error only shows up on a solaris 2.5 machine, "v5.6.1 built for sun4-solaris". It does not show up on a hand full of other machines:
- aix 4.3.3 "version 5.005_03 built for aix"
- debian 2.1 "version 5.004_04 built for i386-linux"
- solaris 2.8 "version 5.005_03 built for sun4-solaris"
- fedora core 4 "v5.8.6 built for i386-linux-thread-multi"
I tried moving the "my $i" to it's own line and the error went away.
# find lines with keywords
my $i;
foreach $i (@keywords) { ## -- now LINE 41 --
if($line =~ m/$i/i) {
# copy found lines to the found lines array
push @found , $line;
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.