summaryrefslogtreecommitdiff
path: root/lib/File/Find
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2004-02-27 16:27:19 +0000
committerNicholas Clark <nick@ccl4.org>2004-02-27 16:27:19 +0000
commitbc125c03185ff3f765451ef53228eea11c0d525f (patch)
tree8e12d4f8f15467759b126f8d25870ca3568c4896 /lib/File/Find
parent15173bafc9a5b667aebe0799fa96768116798dec (diff)
downloadperl-bc125c03185ff3f765451ef53228eea11c0d525f.tar.gz
Create a new local $_ without triggering tie by using local *_ = \my $a
(an idea from Ton Hospel, Message-Id: <c1igq3$n84$1@post.home.lunix>) p4raw-id: //depot/perl@22401
Diffstat (limited to 'lib/File/Find')
-rw-r--r--lib/File/Find/t/find.t39
1 files changed, 37 insertions, 2 deletions
diff --git a/lib/File/Find/t/find.t b/lib/File/Find/t/find.t
index c55b4a9aac..8c312ddee0 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..189\n"; }
-else { print "1..79\n"; }
+if ( $symlink_exists ) { print "1..195\n"; }
+else { print "1..85\n"; }
# Uncomment this to see where File::Find is chdir'ing to. Helpful for
# debugging its little jaunts around the filesystem.
@@ -497,6 +497,41 @@ Check( scalar(keys %Expect_Dir) == 0 );
Check( scalar( keys %pre ) == 0 );
}
+# see thread starting
+# http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2004-02/msg00351.html
+{
+ print "# checking that &_ and %_ are still accessible and that\n",
+ "# tie magic on \$_ is not triggered\n";
+
+ my $true_count;
+ my $sub = 0;
+ sub _ {
+ ++$sub;
+ }
+ my $tie_called = 0;
+
+ package Foo;
+ sub STORE {
+ ++$tie_called;
+ }
+ sub FETCH {return 'N'};
+ sub TIESCALAR {bless []};
+ package main;
+
+ Check( scalar( keys %_ ) == 0 );
+ my @foo = 'n';
+ tie $foo[0], "Foo";
+
+ File::Find::find( sub { $true_count++; $_{$_}++; &_; } , 'fa' ) for @foo;
+ untie $_;
+
+ Check( $tie_called == 0);
+ Check( scalar( keys %_ ) == $true_count );
+ Check( $sub == $true_count );
+ Check( scalar( @foo ) == 1);
+ Check( $foo[0] eq 'N' );
+}
+
if ( $symlink_exists ) {
print "# --- symbolic link tests --- \n";
$FastFileTests_OK= 1;