Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: When <> fails

by pc88mxer (Vicar)
on Jul 29, 2008 at 19:32 UTC ( #700904=note: print w/replies, xml ) Need Help??

in reply to When <> fails

The current file handle that <> is using is stored in ARGV, but my testing shows that perl has alrady closed ARGV when the while (<>) {...} loop terminates.

You might try checking $! to see if that gets set when the NFS server stops serving the file:

while (<>) { ... } # check $! which is probably from the last close
Update: ikegami pointed out that testing $! (as in if ($!) ... doesn't make sense here.

One issue is that $! is only set when there is an error. One way around this is to force a known error at the end of the loop so that you can tell if readline generated an error.

Update 2: One can assign to $!, so this should be able to detect if readline failed:

while (<>) { ... $! = undef; } if (defined($!)) { # $! contains error from last <c>close
} </c>

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://700904]
[stevieb]: choroba my GPS home device is done, at least prototype v1 is. I'm just making sure all of my code does what it says now
[stevieb]: I test/prototype code on my Pi, then I migrate it over to Arduino when it's ready (if that's a better platform for what I'm doing). The whole RPi stuff was for learning at first, then it snowballed. I'm just trying to get my in-house CI...
[stevieb]: ...done, which obviously requires a specific hardware setup.
[stevieb]: I don't write tests for the lower-level distributions (ie. ICs, sensors etc) within those distributions, I have all tests in a master distribution which encompasess all of the sub-modules

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2017-06-25 22:54 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (572 votes). Check out past polls.