Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Any downsides to this slurp idiom? (updated)

by haukex (Archbishop)
on Jun 30, 2018 at 19:34 UTC ( #1217663=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $data = do { open my $fh, '<', $file or die "$file: $!";
        local $/; <$fh> };
    
  2. or download this
    my $data = do { open my $fh, '<:raw:encoding(UTF-8)', $file
        or die "$file: $!"; local $/; <$fh> };
    
  3. or download this
    my $data; { open my $fh, '<', $file or die "$file: $!";
        local $/; $data = <$fh> };
    
  4. or download this
    my $data = do { local (*ARGV,$/); @ARGV=$file; <> };
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2023-03-26 22:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?