ARGV::readonly - make <> open files regardless of leading/trailing whitespace and/or control characters such as |, >, amd <.


ARGV-readonly documentation Contained in the ARGV-readonly distribution.

Index


Code Index:

NAME

Top

ARGV::readonly - make <> open files regardless of leading/trailing whitespace and/or control characters such as |, >, amd <.

SYNOPSIS

Top

this module allows

  use ARGV::readonly;
  while(<>){
       ...

to be safer in hostile environments where one is bullheaded enough to give * as the command line argument. See rants on P5P from July, 2008.

DESCRIPTION

Top

the code is shorter than the documentation. Please look at it.

EXPORT

None by default.

TO DO

Top

ideally a suite of ARGV::* modules will appear, each doing their little thing, in a way that they won't stomp on each other's toes. This module has no exclusion interface or anything, so an @ARGV modifier that, for instance, preprocesses *.gz into "gunzip -c $_ |" is either going to have to undo the mods made here or be incompatible.

HISTORY

Top

0.01

modified suggestion made by Tom Christiansen in Message-ID: <24692.1217339882@chthon>

SEE ALSO

Top

Encode::Argv

July 2008 perl5 porters archive

AUTHOR

Top

furtively assembled by David Nicol <davidnico@cpan.org>

COPYRIGHT AND LICENSE

Top


ARGV-readonly documentation Contained in the ARGV-readonly distribution.

package ARGV::readonly;

use 5.00001;

$VERSION = '0.01';

sub import{
   # Tom Christiansen in Message-ID: <24692.1217339882@chthon>
   # reccomends essentially the following:
   for (@ARGV){
       s/^(\s+)/.\/$1/;	# leading whitespace preserved
       s/^/< /;		# force open for input
       $_.=qq/\0/;	# trailing whitespace preserved & pipes forbidden
   };
};


1;
__END__