How can I tell if a variable is a FileHandle?

P

peterkayatwork

I want to be able to tell if a variable is a FileHandle as opposed to a
string, hash, whatever. I know perl will tell me that it's a Glob:

If I do:

----code:
my $fh=\*STDIN;

print "Have [$fh]\n";
----end of code

it tells me
Have [GLOB(0x10131870)]

Thanks, perl.

If I do an "isa" to see if I've got a glob, what else could it be
besides a FileHandle?

Better yet, is there a more elegent way to tell if I've got a
FileHandle or a String?

--Peter
 
A

Anno Siegel

I want to be able to tell if a variable is a FileHandle as opposed to a
string, hash, whatever. I know perl will tell me that it's a Glob:

See the current thread "GLOB vs IO::Handle"

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top