Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 scrutinizing the Monastery: (16)
As of 2014-11-26 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (171 votes), past polls