Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: multi-line parsing

by AnomalousMonk (Archbishop)
on Mar 31, 2009 at 21:34 UTC ( [id://754544]=note: print w/replies, xml ) Need Help??


in reply to Re: multi-line parsing
in thread multi-line parsing

You could also undef the separator and match globally ...
Be aware that the code given will globally alter the $/ package variable (see perlvar).

A more 'idiomatic' way to slurp the contents of a file without globally changing  $/ (if you do not use the File::Slurp module or an equivalent) is with the statement

my $file_contents = do { local $/; <$file_handle> };
or
my $file_contents = do { local $/; <FILEHANDLE> };

Replies are listed 'Best First'.
Re^3: multi-line parsing
by Nkuvu (Priest) on Mar 31, 2009 at 21:43 UTC

    That's what I get for writing up a note just before lunch. I missed the local (but normally include that when altering the record separator). Thanks for the correction.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://754544]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found