Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

RE: Load file into a scalar without File::Slurp

by turnstep (Parson)
on Jul 17, 2000 at 04:23 UTC ( #22800=note: print w/ replies, xml ) Need Help??


in reply to Load file into a scalar without File::Slurp

Or the semi-obfuscated version: as long as you just emptied out $/, why not use it? :)

{ local $/; $/ .= $_ while <STDIN>; }

P.S. In general, you want to make changes to global variables a temporary condition, as in merlyn's do loop above, and the more general form:

{ local $/; ## This is already undef, no need to set it ## Read in the file, etc... } ## $/ is now back where it was


Comment on RE: Load file into a scalar without File::Slurp
Select or Download Code
Replies are listed 'Best First'.
(chromatic) RE: RE: Load file into a scalar without File::Slurp
by chromatic (Archbishop) on Jul 17, 2000 at 08:09 UTC
    Here's a shorter version of that. I feel dirty:
    { local $/ = <STDIN>; }
    Note to anyone who has to look at $/ to understand this -- do not use this code. It's a seriously ugly thing.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (18)
As of 2015-07-07 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls