Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: How can you sysread an entire file?

by NeilF (Sexton)
on Jan 12, 2006 at 22:23 UTC ( #522822=note: print w/ replies, xml ) Need Help??


in reply to Re: How can you sysread an entire file?
in thread How can you sysread an entire file?

Thanks...

Not sure if I fully understand what you mean by "\n" is not portable? What exactly is the implication. I've run some tests and it seems to work OK on the files I've used it on (Windows XP & Unix).

My ISP counts IO operations. Doing a "while <DF>" would mean an IO operation (I believe) for every 512 bytes of data as it is buffered in. By using sysread the whole file is read in by one IO operation. Hence me going down this approach...


Comment on Re^2: How can you sysread an entire file?
Re^3: How can you sysread an entire file?
by esskar (Deacon) on Jan 12, 2006 at 23:14 UTC
    try this under windows and linux
    use strict; use warnings; open(FILE, '>', 'foo.bar') or die "Daim!"; print FILE "\n"; close FILE;
    under windows, the file will have a size of two bytes (\r\n)- under linux just 1 (\n) comapre it to
    use strict; use warnings; open(FILE, '>', 'foo.bar') or die "Daim!"; binmode FILE; print FILE "\n"; close FILE;
      I'm aware of that... All my files on Windows & Unix follow that rule... What's the problem?

        I linked to a thread that discusses the bug in the two sentence paragraph in which I mentioned the bug. In some versions of Perl, sysread acts as if binmode is on, even when it's not. When binmode is on, "\n" is not the end of line marker, yet you're splitting on "\n".

        Ok, fine, you won't have a problem in Windows until it's time to chomp, when you'll find the "\r" is not being removed along with the "\n".

Log In?
Username:
Password:

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

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

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (152 votes), past polls