Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

(tye)Re5: Slurp a file

by tye (Sage)
on Jan 15, 2001 at 21:19 UTC ( [id://51962]=note: print w/replies, xml ) Need Help??


in reply to Re: Slurp a file
in thread Slurp a file

Unfortunately, this isn't completely portable. There are minor (as far as I can tell) problems with some operating systems where the size of a file on disk doesn't always match the size of data read into memory.

The big problems have to do with the great many types of filehandles where -s can't tell the file size.

But, yes, when it works, this is a neat trick. Thanks.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re5: Slurp a file
by Anonymous Monk on Jan 15, 2001 at 22:42 UTC
    Just a few questions:

    What types of filehandlers would not return the correct size with -s?

    And do you know a better way to get the size of a filehandle than using -s?

      What types of filehandlers would not return the correct size with -s?

      Mostly pipes and user input devices (terminals/consoles). -s pretty much only works on file handles connected to oridinary files. For the other cases, the only way to determine the amount of data before EOF is to read it all.

              - tye (but my friends call me "Tye")

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-25 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found