Friday, January 18, 2013

perl slurp mode


Perl can change the mode of how to read a file.

$/
The input record separator, newline by default. $/ may be set to a value longer than one character in order to match a multi-character delimiter. If $/ is undefined, no record separator is matched, and <FILEHANDLE>will read everything to the end of the current file.   

Example:

open FILEHANDLE, 'somefile.txt' or die $!;
local $/; my $string = <FILEHANDLE>;




No comments:

Post a Comment