Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.9k stars 540 forks source link

search position reset by 'local' save/restore #743

Closed p5pRT closed 20 years ago

p5pRT commented 24 years ago

Migrated from rt.perl.org#1666 (status was 'resolved')

Searchable as RT1666$

p5pRT commented 24 years ago

From oloryn@mindspring.com

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


Site configuration information for perl 5.00553​:

Configured by bcoleman at Sat Feb 13 21​:36​:29 EST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 53) configuration​:   Platform​:   osname=os2\, osvers=2.40\, archname=os2   uname='os2 oloryn 2 2.40 i386 '   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=undef useperlio=undef d_sfio=undef   Compiler​:   cc='gcc'\, optimize='-O2 -fomit-frame-pointer -malign-loops=2 -malign-jumps=2 -malign-functions=2 -s'\, gccversion=2.7.2.1   cppflags='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I.'   ccflags ='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I.'   stdchar='char'\, d_stdstdio=define\, usevfork=false   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12   alignbytes=4\, usemymalloc=y\, prototype=define   Linker and Libraries​:   ld='gcc'\, ldflags ='-Zexe -Zomf -Zmt -Zcrtdll -Zstack 32000'   libpth=g​:/emx/lib G​:/JAVA11/LIB g​:/emx/lib/mt   libs=-lsocket -lm -lbsd   libc=g​:/emx/lib/mt/c_import.lib\, so=dll\, useshrplib=true\, libperl=libperl.lib   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=dll\, d_dlsymun=undef\, ccdlflags=' '   cccdlflags='-Zdll'\, lddlflags='-Zdll -Zomf -Zmt -Zcrtdll -s'

Locally applied patches​:  


@​INC for perl 5.00553​:   g​:/perl/lib/5.00553/os2   g​:/perl/lib/5.00553   g​:/perl/lib/site_perl/5.00553/os2   g​:/perl/lib/site_perl/5.00553   .


Environment for perl 5.00553​:   HOME=F​:\home\   LANG=EN_US   LD_LIBRARY_PATH (unset)   LOGDIR (unset)  

PATH=F​:\NETSCAPE\PROGRAM;H​:\MPTN\BIN;H​:\IBMCOM;G​:\GNU\BIN;H​:\OS2;H​:\OS2\

SYSTEM;H​:\OS2\MDOS\WINOS2;H​:\OS2\INSTALL;H​:\;H​:\OS2\MDOS;H​:\OS2\APPS;H​:\

MMOS2;G​:\EMX\BIN;F​:\OS2BIN;F​:\OS2BIN\PERL;G​:\EPM;G​:\TS\OS2_SYS;F​:\PGP26;

F​:\BACKMAST;F​:\INCHARGE;F​:\BONUSPAK\IBMWORKS;H​:\TCPIP\BIN;H​:\TCPIP\PCOMO

S2;H​:\TCPIP\UMAIL;G​:\PERL\BIN;G​:\PERL\OS2BIN;F​:\BA2PRO;F​:\PERF_30;F​:\PER

F_30;G​:\XFree86\bin;F​:\Office50;H​:\JAVA11\BIN;F​:\emtex\bin;F​:\gstools\gs

5.50;   PERL_BADLANG=0   PERL_BADLANG=0   PERL_SH_DIR=G​:\GNU\BIN   SHELL (unset)

-- Ben Coleman oloryn@​mindspring.com | The attempt to legislatively http​://oloryn.home.mindspring.com/ | micromanage equality results\, at   | best\, in equal misery for all.

p5pRT commented 24 years ago

From @mjdominus

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

Éric Brunet reported this on Monday. The Subject​: was

  BUG​: local scope modifies pos()

Thanks for sedning in the second report.