in reply to Interesting: a genuine Perl-bug

Unfortunately, this is at $WORK, so I can’t easily try other versions.

In my code, the error-message was reported on a line ... other than the my $state; declaration ... where the offending variable did appear, just not the place where (it did!) occur as a bareword.   Hence, the code looked more like this:

my $state = 0; ... $state = 1; #<--- BAREWORD REPORTED HERE ... $state = 4; ... state = 5; #<--- BUT THE BAREWORD IS ACTUALLY HERE

The message line-number was not simply “off by some random amount.”   The variable did indeed occur as a bareword, elsewhere in the program.   The message simply cited the wrong line.

Replies are listed 'Best First'.
Re^2: Interesting: a genuine Perl-bug
by toolic (Bishop) on Sep 22, 2010 at 14:05 UTC
    I can not repeat your problem on my system with 5.10.0. The message points to the correct line:
    $ cat foo.pl my $state = 0; print "state = $state\n"; $state = 1; print "state = $state\n"; $state = 4; print "state = $state\n"; state = 5; print "state = $state\n"; $ $ perl -Mstrict foo.pl Can't modify constant item in scalar assignment at foo.pl line 7, near + "5;" Bareword "state" not allowed while "strict subs" in use at foo.pl line + 7. Execution of foo.pl aborted due to compilation errors. $ $ perl -v This is perl, v5.10.0 built for x86_64-linux Copyright 1987-2007, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. $

    I also tried Perl versions 5.8.8 and 5.12.0.

Re^2: Interesting: a genuine Perl-bug (case)
by tye (Sage) on Sep 22, 2010 at 14:00 UTC

    That's an interesting theory. But, as you found, the effect is quite unfortunate for the one trying to fix the error. I would personally love to see an example that can reproduce the problem. And such would make it more likely that the bug gets fixed. Thanks.

    - tye