Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: mysterious error of read function in solaris

by JavaFan (Canon)
on Jan 19, 2012 at 15:46 UTC ( #948794=note: print w/ replies, xml ) Need Help??


in reply to Re^2: mysterious error of read function in solaris
in thread mysterious error of read function in solaris

Whatever variable you put the return value of read in. From perldoc -f read

Returns the number of characters actually read, 0 at end of file, or undef if there was an error (in the latter case $! is also set).
So, you'd do something like:
my $r; while ($r = read ...) { ... do stuff here ... } die "read failed: $!" unless defined $r;
I guess since 5.10, you could also write:
while (read(...) // die "read failed: $!") { ... do stuff here ... }
but I don't think I would want to recommend that.


Comment on Re^3: mysterious error of read function in solaris
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (14)
As of 2014-12-22 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (126 votes), past polls