diff options
author | Moritz Lenz <moritz@casella.verplant.org> | 2008-10-30 21:30:00 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2008-10-30 21:33:34 +0000 |
commit | 48ab5743872e4822467917893ea754a3fd36e1cb (patch) | |
tree | e2c34d3d5141d0e74bbafbb8a8264a1befa14de6 /pod | |
parent | db42c9028c2e0e8bf2d418f40276d99e5fbaf04c (diff) | |
download | perl-48ab5743872e4822467917893ea754a3fd36e1cb.tar.gz |
Re: [PATCH] [doc] be more explicit about magic argv
Message-ID: <20081030182902.25398.qmail@lists.develooper.com>
p4raw-id: //depot/perl@34670
Diffstat (limited to 'pod')
-rw-r--r-- | pod/perlop.pod | 12 | ||||
-rw-r--r-- | pod/perlrun.pod | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod index 7b0b0d2294..f52f79f5be 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -2246,6 +2246,18 @@ internally--<> is just a synonym for <ARGV>, which is magical. (The pseudo code above doesn't work because it treats <ARGV> as non-magical.) +Since the null filehandle uses the two argument form of L<perlfunc/open> +it interprets special characters, so if you have a script like this: + + while (<>) { + print; + } + +and call it with C<perl dangerous.pl 'rm -rfv *|'>, it actually opens a +pipe, executes the C<rm> command and reads C<rm>'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<ARGV::readonly> 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 c2b53932eb..1b8f1a0296 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<perlfunc/open>, which doesn't necessarily interpret them as file names. +See L<perlop> for possible security implications. + Here is an efficient way to delete all files that haven't been modified for at least a week: |