Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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


Comment on Re: Accepting either a filename or a handle
Download Code

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 web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2014-10-23 03:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (123 votes), past polls