Re: Help slurping a file?
[email protected] (David Graff)
| Newsgroups | perl.unicode |
|---|---|
| Message-ID | <[email protected]> |
You probably noticed that I forgot to localize $/ in that snippet I sent
previously (not that it matters in this case -- just a point of maintaining
good habits):
#!/usr/local/bin/perl
my $fname = "path/name_of.file";
open( IN, $fname );
{
local $/ = undef;
$_ = <IN>;
}
close IN;
printf("File size = %d, slurped string size = %d\n", -s $fname, length());
__END__