From: David Landgren Date: Mon, 24 Apr 2006 13:02:02 +0000 (+0200) Subject: Re: [perl #38965] File::Find documentation - is "Don't modify thesevariables" still... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=668a78bfe3bf9a6d16f5b059341fb64b1e120158;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #38965] File::Find documentation - is "Don't modify thesevariables" still valid? Message-ID: <444CB02A.2000604@landgren.net> p4raw-id: //depot/perl@27953 --- diff --git a/lib/File/Find.pm b/lib/File/Find.pm index 497051e..9c81c6a 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 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 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 or are in effect, there is also a C<$File::Find::fullname>. The function may set