If the open is successful it will return the first line in the file that was passed as a parameter when the function was called. If the open is unsuccessful, the logical short circuit stops at the open, and returns what it returned upon failure, which is undef.
It's important to observe that one must test explicitly whether the return value is "defined". In an error condition, it will not be. Testing the return value for truth/falsehood isn't sufficient, since the first line of a file could be a value that Perl considers false.
Update: I had kinda lost track of this thread, not realizing that there had been additional discussion. But Skeeve correctly pointed out to me that his explanation in Re: what is the return value is accurate, and mine isn't. The flaw in my analysis is that the my $in variable will not have been instantiated. My analysis would have been accurate had $in been pre-declared ahead of the open, but it wasn't, and Skeeve's analysis is spot on.
Dave
In reply to Re: what is the return value
by davido
in thread what is the return value
by arasumg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |