Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

RE: Return the contents of a file

by turnstep (Parson)
on Apr 12, 2000 at 18:02 UTC ( [id://7382]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub readfile {
      local $/="" unless wantarray;
      return open(FS, shift) ? <FS> : undef;
    }
    
  2. or download this
    defined($slurp = &readfile($file)) or die "Could not open $file: $!\n"
    +;
    print "Scalar 'slurp' now has ", length $slurp, " characters in it\n";
    defined(@slurp = &readfile($file)) or die "Could not open $file: $!\n"
    +;
    print "Array 'slurp' now has ", $#slurp, " elements in it.\n";
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-19 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found