in reply to Re: escaping filenames taken in via user input
in thread escaping filenames taken in via user input
See perldoc perlvar on the intricacies of $/. Note that this code uses a lexical to store the filehandle - it needs Perl 5.6 or newer to work that way, but affords us the luxury of not closing the file explicity. It just gets autoclosed when the $fh goes out of scope at the end of the block.if(..) { open my $fh, "<", $filename or die &cant_open_file; local $/ = \8192; # read in 8 kbyte chunks rather than line by lin +e print while <$fh>; }
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^2: escaping filenames taken in via user input
by stupidius (Initiate) on Oct 30, 2002 at 01:21 UTC |