From: Jos I. Boumans Date: Thu, 16 Jan 2003 14:04:48 +0000 (+0100) Subject: Re: [perl #19977] unlocalized $_ in File::Find clobbers upstream $_ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=17ab9c147afa44f9f620bca432b3948e42711043;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #19977] unlocalized $_ in File::Find clobbers upstream $_ From: "Jos I. Boumans" Message-ID: <3E26ADF0.6010605@dwim.org> (with test tweaks) p4raw-id: //depot/perl@18501 --- diff --git a/lib/File/Find.pm b/lib/File/Find.pm index 72fd195..8953e97 100644 --- a/lib/File/Find.pm +++ b/lib/File/Find.pm @@ -568,7 +568,7 @@ sub _find_opt { local ($wanted_callback, $avoid_nlink, $bydepth, $no_chdir, $follow, $follow_skip, $full_check, $untaint, $untaint_skip, $untaint_pat, $pre_process, $post_process, $dangling_symlinks); - local($dir, $name, $fullname, $prune); + local($dir, $name, $fullname, $prune, $_); my $cwd = $wanted->{bydepth} ? Cwd::fastcwd() : Cwd::getcwd(); my $cwd_untainted = $cwd; diff --git a/lib/File/Find/t/find.t b/lib/File/Find/t/find.t index 4e5a217..c55b4a9 100644 --- a/lib/File/Find/t/find.t +++ b/lib/File/Find/t/find.t @@ -15,8 +15,8 @@ BEGIN { $SIG{'__WARN__'} = sub { $warn_msg = $_[0]; warn "# $_[0]"; } } -if ( $symlink_exists ) { print "1..188\n"; } -else { print "1..78\n"; } +if ( $symlink_exists ) { print "1..189\n"; } +else { print "1..79\n"; } # Uncomment this to see where File::Find is chdir'ing to. Helpful for # debugging its little jaunts around the filesystem. @@ -484,6 +484,18 @@ File::Find::find( {wanted => \&noop_wanted, Check( scalar(keys %Expect_Dir) == 0 ); +{ + print "# checking argument localization\n"; + + ### this checks the fix of perlbug [19977] ### + my @foo = qw( a b c d e f ); + my %pre = map { $_ => } @foo; + + File::Find::find( sub { } , 'fa' ) for @foo; + delete $pre{$_} for @foo; + + Check( scalar( keys %pre ) == 0 ); +} if ( $symlink_exists ) { print "# --- symbolic link tests --- \n"; @@ -761,5 +773,4 @@ if ( $symlink_exists ) { Check( scalar(keys %Expect_File) == 0 ); unlink file_path('fa', 'faa_sl'); -} - +}