[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Read entire file?



Jim Correia wrote:
> 
> So I'm a c programmer, and my perl book is at the office.

Poor unforturnet soul.
> 
> What is the best (fastest, clearest code) to read an entire file into a
> variable?  I want to preserve whatever line endings were in the original
> file so I don't want to read it by lines.

 undef $/;
 $_ = <FH>;          # whole file now here

>                                           Right now I am reading by
> chunks because I can't seem to find a function that will return the size
> in bytes of the file on disk...

my $size = -s "filename";

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org