Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: "open" Best Practices

by hippo (Chancellor)
on Jul 13, 2019 at 10:25 UTC ( #11102786=note: print w/replies, xml ) Need Help??


in reply to Re^4: "open" Best Practices
in thread "open" Best Practices

What do you think about if( open($fh, '<', $foo) || open($fh, '<', $bar)

Dogfood time? ;-)

for my $infile ($foo, $bar) { last if open ($fh, '<', $infile); warn "Cannot open '$infile' for reading: $!"; } unless (eof $fh) { ... } else { warn "None of the files could be opened. What a shame."; }

I take your point though and there it's arguable whether on not it's control flow. I would not object to either || or or in such a situation.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2020-02-19 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (80 votes). Check out past polls.

    Notices?