From: Moritz Lenz Date: Thu, 30 Oct 2008 20:30:00 +0000 (+0100) Subject: Re: [PATCH] [doc] be more explicit about magic argv X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=48ab5743872e4822467917893ea754a3fd36e1cb;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] [doc] be more explicit about magic argv Message-ID: <20081030182902.25398.qmail@lists.develooper.com> p4raw-id: //depot/perl@34670 --- diff --git a/pod/perlop.pod b/pod/perlop.pod index 7b0b0d2..f52f79f 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -2246,6 +2246,18 @@ internally--<> is just a synonym for , which is magical. (The pseudo code above doesn't work because it treats as non-magical.) +Since the null filehandle uses the two argument form of L +it interprets special characters, so if you have a script like this: + + while (<>) { + print; + } + +and call it with C, it actually opens a +pipe, executes the C command and reads C's output from that pipe. +If you want all items in C<@ARGV> to be interpreted as file names, you +can use the module C from CPAN. + You can modify @ARGV before the first <> as long as the array ends up containing the list of filenames you really want. Line numbers (C<$.>) continue as though the input were one big happy file. See the example diff --git a/pod/perlrun.pod b/pod/perlrun.pod index c2b5393..1b8f1a0 100644 --- a/pod/perlrun.pod +++ b/pod/perlrun.pod @@ -655,6 +655,10 @@ Note that the lines are not printed by default. See B<-p> to have lines printed. If a file named by an argument cannot be opened for some reason, Perl warns you about it and moves on to the next file. +Also note that C<< <> >> passes command line arguments to +L, which doesn't necessarily interpret them as file names. +See L for possible security implications. + Here is an efficient way to delete all files that haven't been modified for at least a week: