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

Re^3: simply appending to a scalar...

by ikegami (Patriarch)
on Jun 28, 2006 at 04:48 UTC ( #557926=note: print w/replies, xml ) Need Help??


in reply to Re^2: simply appending to a scalar...
in thread simply appending to a scalar...

Only use print, read, <FILE> and eof with files opened with open.

Similarly, only use syswrite and sysread with files opened with sysopen.

Replies are listed 'Best First'.
Re^4: simply appending to a scalar...
by abachus (Monk) on Jun 28, 2006 at 13:00 UTC
    Ah, is it an absolute rule not to use open with sysread/syswrite ?
    The reason I ask is that i've had no obvious problems before using something like :

    open(HANDLE,"+>$name") or die $!;


    Then say a four way select() & sysread() until sysread returns 0. Same can be said for syswrite() but without the select() and zero byte check.

    I'm aware that print and read are buffered, but i'm aware of little more than that ;-)

    To conclude, i reckon i will implement what was first decided on Sunday, and that is using sysread() to fill up the target scalar, it has been interesting however to have seen the other options, TMTOWTDI indeed.

    regards,

    Isaac.

      I could be wrong. I can't find anything in the documentation saying you can't use sys* on a filehandle opened with open. Maybe it works on some systems but not on others (like sockets requiring the use of the system functions). Maybe it's a convention I adopted to be on the safe side.

      However, you definitely can't intermiggle buffered and system file operations. For example, I can across a piece of code that used select, eof and sysread. It didn't work because sysread always returned 0. eof would move the data from the pipe into the buffer. After changing sysread to read, everything worked fine.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2022-10-01 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (126 votes). Check out past polls.

    Notices?