diff options
author | David Landgren <david@landgren.net> | 2006-04-24 15:02:02 +0200 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2006-04-24 15:27:39 +0000 |
commit | 668a78bfe3bf9a6d16f5b059341fb64b1e120158 (patch) | |
tree | 5940a93ab4d110e4ce99820331550dd2472f345a /lib/File/Find.pm | |
parent | ce5e94717f361c3fd6b9b0fb704412d30f3ccf66 (diff) | |
download | perl-668a78bfe3bf9a6d16f5b059341fb64b1e120158.tar.gz |
Re: [perl #38965] File::Find documentation - is "Don't modify thesevariables" still valid?
Message-ID: <444CB02A.2000604@landgren.net>
p4raw-id: //depot/perl@27953
Diffstat (limited to 'lib/File/Find.pm')
-rw-r--r-- | lib/File/Find.pm | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/File/Find.pm b/lib/File/Find.pm index 497051e063..9c81c6ad50 100644 --- a/lib/File/Find.pm +++ b/lib/File/Find.pm @@ -215,8 +215,6 @@ through a collection of variables. =back -Don't modify these variables. - For example, when examining the file F</some/path/foo.ext> you will have: $File::Find::dir = /some/path/ @@ -239,6 +237,18 @@ table below summarizes all variants: /etc / /etc /etc/x /etc /etc/x +Do not modify these variables. If you want to use C<$_>, it must +be restored to its initial value before returning from the +function. C<local> may be used for this purpose: + + sub callback { + open my $fh, '<', $_ or die "Cannot open $_ for input: $!\n"; + local $_; # localize $_ for the remainder of the routine + while (<$fh>) { + # manipulate $_ + } + # $_ will be restored upon leaving + } When <follow> or <follow_fast> are in effect, there is also a C<$File::Find::fullname>. The function may set |