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

Re: [FWP] beauty vs. brains



On Mar 16, Tom Christiansen said:

>>>>   $file = do { local $/, <FILE> };
>>>>   read(FILE, $file, -s FILE);

>And you do realize, I hope, that -s doesn't work on everything, be
>it stat(2) or fstat(2) based.  Do you understand why not?

No, I do not.  I don't have a terribly strong background in the workings
of the C functions that Perl uses, and while I can always ``man -s 2
stat'', there's no guarantee I'll fully grok that.  And if I do, that
doesn't guarantee I'll realize why.  If you're referring to non-regular
files, then yes, I know (from stat(2)):

     st_size   For regular files, this is the address of the  end
               of  the file.  For block special or character spe-
               cial, this is not defined.  See also pipe(2).

>It's also not scalable.  Here's a 7gb logfile: read that one a one
>fell swoop, why doncha?  The only sane, scalable, and portable

Well, seeing as how I know better than to use it on files of that size
(because yes, it is totally unreasonable), I know it's not scalable.  I
use it when I need to read files, but I could care less about how many
lines they have -- I just want to print the data.

-- 
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve             japhy@pobox.com
http://www.pobox.com/~japhy/                  http://pinyaj.stu.rpi.edu/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe