Skip Menu |
Report information
Id: 76026
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: nicholas <nick [at]>

Operating System: freebsd
PatchStatus: (no value)
Severity: low
Type: regex
Perl Version: (no value)
Fixed In: (no value)

Subject: match variables persist between calls to a sort subroutine
Date: Wed, 23 Jun 2010 22:36:43 +0100
To: perlbug [...]
From: Nicholas Clark <nick [...]>
Download (untitled) / with headers
text/plain 3.9k
This is a bug report for perl from, generated with the help of perlbug 1.26 running under perl 5.00503. ----------------------------------------------------------------- [Please enter your report here] $ cat ~/tmp/ #!perl -w use strict; sub sorter { my $result = $a <=> $b; warn $1; # And then "Leakage" =~ /(.*)/; $result; } "Win" =~ /(.*)/; warn "\$1 = '$1'"; my @b = sort sorter 0..2; warn "\$1 = '$1'"; print "@b\n"; print "\nNote the different behaviour for a regular function call:\n"; $a = $b = 0; sorter(); sorter(); __END__ $ ~/Reference/5.005_03/bin/perl5.00503 ~/tmp/ $1 = 'Win' at /export/home/nwc10/tmp/ line 16. Win at /export/home/nwc10/tmp/ line 7. Leakage at /export/home/nwc10/tmp/ line 7. $1 = 'Win' at /export/home/nwc10/tmp/ line 20. 0 1 2 Note the different behaviour for a regular function call: Win at /export/home/nwc10/tmp/ line 7. Win at /export/home/nwc10/tmp/ line 7. I believe that the output should be 'Win' every time. I suspect that this has been a bug forever. (Well, since perl 2, which added sort). However, it may realistically be a bug, as 4.036 exhibits this behaviour: $ /usr/local/perl4/bin/perl4.036 $1 = 'Win' at line 15. Win at line 6. Leakage at line 6. $1 = 'Leakage' at line 19. 0 1 2 Note the different behaviour for a regular function call: Leakage at line 6. Leakage at line 6. ie $1 persists between all calls to the subroutine. Alternatively, I may have missed a documented change in behaviour between perl 4 and perl 5. I've not (yet) been able to build perl 2, to see what it thinks. (obviously) still present in blead, else I wouldn't be reporting it. Nicholas Clark [Please do not change anything below this line] ----------------------------------------------------------------- --- Site configuration information for perl 5.00503: Configured by nwc10 at Wed Mar 14 19:16:50 GMT 2007. Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: osname=freebsd, osvers=6.1-prerelease, archname=i386-freebsd uname='freebsd 6.1-prerelease freebsd 6.1-prerelease #0: tue mar 28 23:04:45 bst 2006 i386 ' hint=recommended, useposix=true, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='ccache gcc', optimize='-g', gccversion=3.4.4 [FreeBSD] 20050518 cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -I/usr/local/include' ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -I/usr/local/include' stdchar='char', d_stdstdio=undef, usevfork=true intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='gcc', ldflags ='-Wl,-E -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lgdbm -lm -lc -lcrypt libc=, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib' Locally applied patches: --- @INC for perl 5.00503: /export/home/nwc10/Reference/5.005_03/lib/perl5/5.00503/i386-freebsd /export/home/nwc10/Reference/5.005_03/lib/perl5/5.00503 /export/home/nwc10/Reference/5.005_03/lib/perl5/site_perl/5.005/i386-freebsd /export/home/nwc10/Reference/5.005_03/lib/perl5/site_perl/5.005 . --- Environment for perl 5.00503: HOME=/export/home/nwc10 LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/export/home/nwc10/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/export/home/nwc10/bin:/usr/local/sbin:/sbin:/usr/sbin PERL_BADLANG (unset) SHELL=/usr/local/bin/bash
Fixed by ad021bf.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at