Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: mysterious error of read function in solaris

by david2008 (Scribe)
on Jan 19, 2012 at 15:39 UTC ( #948793=note: print w/replies, xml ) Need Help??


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

Which variable should i check if read fails?
  • Comment on Re^2: mysterious error of read function in solaris

Replies are listed 'Best First'.
Re^3: mysterious error of read function in solaris
by JavaFan (Canon) on Jan 19, 2012 at 15:46 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948793]
help
Chatterbox?
[Discipulus]: yes, some semantic for the searxh must implemented before using such kind of query
[Corion]: Yeah - I have either to come up with a better search query or simply steal the template of some other file download site... I'm thinking of turning the JSON for Strawberry Perl releases into a small website that offers the files for download, with a ...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-02-28 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (398 votes). Check out past polls.