in reply to Grokking Compile Error Messages

I'd like to see an example of the error such that Perl complains about multiple "my" declarations when there was only one.

- tye        

  • Comment on Re: Grokking Compile Error Messages (details)

Replies are listed 'Best First'.
Re^2: Grokking Compile Error Messages (details)
by QM (Parson) on Jul 21, 2004 at 17:45 UTC
    This code:
    #!/your/perl/here use strict; use warnings; if (( 1) # missing closing paren { my $x; ($x) = 'abc' =~ /(b)/; $x++; }
    generates these errors:
    C:\Perl\perl>perl -c syntax_error2.pl "my" variable $x masks earlier declaration in same scope at syntax_err +or2.pl line 9. "my" variable $x masks earlier declaration in same scope at syntax_err +or2.pl line 10. syntax error at syntax_error2.pl line 7, near ") # missing closing par +en {" syntax error at syntax_error2.pl line 11, near "}" syntax_error2.pl had compilation errors.
    In the real code, several variables (which had been declared outside of the if block) were referenced, and were reported as "masking".

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of