Closed p5pRT closed 16 years ago
The following behavior is arguably both wrong and right\, I'm for the moment arguing for the former.
In here-documents an error (I think whichever error\, that is of no concern here\, I think) is reported to the line where the here-doc begins. If the doc is large\, this can be rather frustrating.
The following example works only for _5X which have the utf8 pragma\, this is where I met this problem. The 8-bit adiaereses (if some mail gateway has eaten your high bit\, the middle line of the here-doc is bär in HTML-speak) is rightfully reported is malformed UTF-8 character (no problem in there\, utf8 is right in reporting that)\, but the error is reported for the line where the here-doc begins\, not to the line where the problem is.
The code:
$x = \<\<EOF; foo bär zog EOF print $x\, "\n";
and the result:
./perl -Ilib -Mutf8 -w X
Malformed UTF-8 character at X line 1.
foo
bär
zog
After upgrade\, a reference in a script for a html footer such as this
\\E-mail: webmaster@buscout.com\\\\
worked flawlessly in perl 5.0004 after upgrade\, it was required to have this syntax in order to work:
\\E-mail: webmaster\@buscout.com\\\\
Now the error reported as when run from command line:
In string\, @buscout now must be written as \@buscout at ./test.cgi line 13\, near "@buscout" Execution of ./test.cgi aborted due to compilation errors.
yet this line is nowhere near line 13 but at line 87
line 13 is print \<\<EndOfHTML;
Dont know if there is a backward compat issue here or an oversight.. thanks for all your efforts.
On Apr 18\, Adam Simpson said:
\\E-mail: webmaster\@buscout.com\\\\
In string\, @buscout now must be written as \@buscout at ./test.cgi line 13\, near "@buscout" Execution of ./test.cgi aborted due to compilation errors.
yet this line is nowhere near line 13 but at line 87
line 13 is print \<\<EndOfHTML;
Your quoted string starts at line 13. Take this as another example of when line numbers may not be as you expect:
#!/usr/bin/perl -w if (0 or 0 * $foo or 0 * $bar or 1) { print "ok" }
Name "main::foo" used only once: possible typo at - line 4. Name "main::bar" used only once: possible typo at - line 5. Use of uninitialized value at - line 2. Use of uninitialized value at - line 2.
While Perl knows $foo and $bar are mentioned explicitly on lines 4 and 5\, it reads your entire if statement as one line (please\, someone\, give a more suitable explanation of that).
On Apr 18\, Jeff Pinyan said:
Your quoted string starts at line 13. Take this as another example of
As O::Deparse shows me:
jeffp@friday [12:54pm] ~ #436> perl -MO=Deparse print \<\< "END"; testing this out $$ right now END - syntax OK print "testing\nthis\nout\n$$ right now\n";
Jeff Pinyan writes:
While Perl knows $foo and $bar are mentioned explicitly on lines 4 and 5\, it reads your entire if statement as one line (please\, someone\, give a more suitable explanation of that).
Diagnostic messages read the line-number-of-currently-executed-chunk-of-code from some memory location. This memory location should be reset when flow of execution winds around. It is reset at the beginning of each statement.
Resetting it more often would slow things down\, keeping the line-number at each opcode would take a lot of memory.
Hope this helps\, Ilya
Ilya Zakharevich \ilya@​math\.ohio\-state\.edu writes: | Jeff Pinyan writes: | > While Perl knows $foo and $bar are mentioned explicitly on lines 4 and 5\, | > it reads your entire if statement as one line (please\, someone\, give a | > more suitable explanation of that). | ||||
---|---|---|---|---|---|---|---|---|
Diagnostic messages read the | ||||||||
line-number-of-currently-executed-chunk-of-code from some memory | ||||||||
location. This memory location should be reset when flow of execution | ||||||||
winds around. It is reset at the beginning of each statement. | ||||||||
Resetting it more often would slow things down\, keeping the | ||||||||
line-number at each opcode would take a lot of memory. |
If the diagnostic also has access to the current opcode structure\, and if there are a few bits available in the opcode structure\, it could contain an offset from the line number of the beginning of the statement. If the offset was 3 bits\, the value 7 would mean:
"on or after line " . ($n+7) . " in the statement starting on line $n"
Values 1..6 of OFFSET would mean:
"on line " . ($n+OFFSET) . " in the statement starting on line $n"
And a value of 0 would issue:
"on line $n"
Since statements are usually very short (usually one line)\, this would allow almost all diagnostics to be accurate to the position of the opcode as well as noting the line number that starts the statement.
This bug is not specific to here-docs but to any string.
[~] perl -w my $bar = undef; my $foo = qq{ # line 4 basset hounds got long $bar and such }; Use of uninitialized value in concatenation (.) or string at - line 2.
[schwern - Fri Jun 25 14:40:49 2004]: my $foo = qq{ # line 4
Ignore that comment.
Won't be fixed.
Relevant p5p messages: http://www.nntp.perl.org/group/perl.perl5.porters/2008/04/msg136273. html http://www.nntp.perl.org/group/perl.perl5.porters/2008/04/msg136277. html
Comments:
#!/usr/bin/perl -l
use strict; use warnings;
my $foo;
my $x = \<\<EOF; foo $foo zog EOF __END__ Output: Use of uninitialized value in concatenation (.) or string at a.pl line 8.
Where one might expect: Use of uninitialized value in concatenation (.) or string at a.pl line 10. (the line with $foo)
Won't fix. The string (or heredoc) is seen as one token.
#!/usr/bin/perl -l
use warnings;
if (0 or 0 * $foo or 0 * $bar or 1) { $_="ok" } __END__ Output: Name "main::bar" used only once: possible typo at a.pl line 8. Name "main::foo" used only once: possible typo at a.pl line 7. Use of uninitialized value $foo in multiplication (*) at a.pl line 5. Use of uninitialized value $bar in multiplication (*) at a.pl line 5.
Where one might expect: Name "main::bar" used only once: possible typo at a.pl line 8. Name "main::foo" used only once: possible typo at a.pl line 7. Use of uninitialized value $foo in multiplication (*) at a.pl line 7. Use of uninitialized value $bar in multiplication (*) at a.pl line 8.
Won't fix. Only control ops store file names and line numbers\, not every op\, for space efficiency. So the first line of the expression is reported.
p5p@spam.wizbit.be - Status changed from 'open' to 'rejected'
Migrated from rt.perl.org#1034 (status was 'rejected')
Searchable as RT1034$