Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Accepting either a filename or a handle

by broquaint (Abbot)
on Jun 21, 2004 at 03:57 UTC ( #368360=note: print w/replies, xml ) Need Help??


in reply to Accepting either a filename or a handle

There's a function in Module::Locate that determines whether a scalar acts like a filehandle or not. So with that you could do something like this in your function
use Module::Locate 'acts_like_fh'; sub fizbin { my($str, $infh, $outfh) = @_; -e $_ or acts_like_fh $_ or die "Invalid file name/handle '$_'" for $infh, $outfh; ... }
HTH

_________
broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://368360]
help
Chatterbox?
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2017-10-21 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (270 votes). Check out past polls.

    Notices?