Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: read()

by archen (Pilgrim)
on Dec 31, 2001 at 20:24 UTC ( #135381=note: print w/ replies, xml ) Need Help??


in reply to read()

What you say is all true when dealing with text files, but when it comes to dealing with non text files (like an mp3, or jpeg), read() is probably going to be your only solution since you really can't read those types of files line by line, and who knows what you'll get in an array. The usefulness of read is best understood when you understand it's compliment function seek() (well to me anyway). With these two functions you can jump around a file and read various amounts of data, without worrying about hitting an unexpected \n.


Comment on Re: read()
Select or Download Code
Re^2: read()
by Anonymous Monk on Jun 08, 2007 at 03:10 UTC
    Why can't you `my @data = <FILEHANDLE>;` for binary data? It won't exactly be logically split, but `my $r = join '', @data` works perfectly fine.... Of course, I wouldn't want a huge file in memory...
      This way you effectively pwn all of the chr(10) in your binary file... which is bad. The better "slurping" solution is to undef$/ and then using <>;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2014-09-23 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls