develooper Front page | perl.perl5.porters | Postings from December 2000

[ID 19991026.002] search position reset after 'local' save/restore

From:
Stephen P. Potter
Date:
December 14, 2000 11:30
Subject:
[ID 19991026.002] search position reset after 'local' save/restore
Message ID:
200012142028.PAA01673@spotter.yi.org
Still true as of @8079.

This is a bug report for perl from oloryn@mindspring.com,
 generated with the help of perlbug 1.26 running under perl 5.00553.

 jalex mentioned this on #perl.  I'm not sure if he sent in a bug report
 or not.

 This program: 

 #!/usr/bin/perl -w
 $x = "123 56";  $x =~ / /g;
 print "$x, ", pos($x), "\n";
 { local $x }
 print "$x, ", pos($x), "\n";

 produces the output

 123 56, 4
 123 56, Use of uninitialized value at test.plx line 5.

 The search position for a match appears to be reset when the target 
 variable goes through a 'local' save and restore.

 I get the same results on 5.005_03 on linux.

 Ben



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About