in reply to Re^4: substr oddity
in thread Perl oddities
Yep! That's the entire output. I've added a couple of print $]; statements, one in an END{} block, to these to show that I get some output, which means that STDOUT must be being flushed, which I assume is a clean-up time operation:
P:\test>perl -l END{ print $] } print $]; use strict; use warnings; my $x=""; foo( substr($x,2,1) ); # crashes here print "Alive!\n"; # not reached sub foo {} ^Z 5.008004 substr outside of string at - line 6. 5.008004 P:\test>c:\perl561\bin\perl5.6.1.exe -l END{ print $] } print $]; use strict; use warnings; my $x=""; foo( substr($x,2,1) ); # crashes here print "Alive!\n"; # not reached sub foo {} ^Z 5.006001 substr outside of string at - line 6. 5.006001 P:\test>
However, if I remove the subcall from the picture:
P:\test>perl use strict; use warnings; my $x=""; print substr($x,2,1); # crashes here print "Alive!\n"; # not reached ^Z substr outside of string at - line 4. Use of uninitialized value in print at - line 4. Alive! P:\test>c:\perl561\bin\perl5.6.1.exe use strict; use warnings; my $x=""; print substr($x,2,1); # crashes here print "Alive!\n"; # not reached ^Z substr outside of string at - line 4. Use of uninitialized value in print at - line 4. Alive! P:\test>
Which indicates that the execution path is being truncated or short ciruited when the subcall is in place, but no crash, just a silent move to the END{} of the program--which isn't very freindly.
Seems to be a Win32 thing, and one probably worth reporting even though I cannot see how to provide any sort of indication of where the problem might occur?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: substr oddity
by Anonymous Monk on Mar 04, 2005 at 23:12 UTC | |
by BrowserUk (Patriarch) on Mar 04, 2005 at 23:55 UTC | |
by Ytrew (Pilgrim) on Mar 07, 2005 at 02:39 UTC |