To know if a variable is a file handler

  • Thread starter Luis Angel Fdez. Fdez.
  • Start date
L

Luis Angel Fdez. Fdez.

Hi!

I was looking in Google and I don't find anything that solves my
doubt. Is there any way I can check if a variable is an file handler
of an opened file?.

Thanks in advance.

Bye!
 
S

Sisyphus

Luis Angel Fdez. Fdez. said:
Hi!

I was looking in Google and I don't find anything that solves my
doubt. Is there any way I can check if a variable is an file handler
of an opened file?.

Thanks in advance.

# Untested
use warnings;
use strict;
use FileHandle::Fmode qw:)all);
my $fh;
# (optionally) other code that does stuff
if is_arg_ok($fh) {print "\$fh is a file handle to an open file"}
else {print "\$fh is NOT a file handle to an open file"}
__END__

Cheers,
Rob
 
J

John W. Krahn

Luis said:
I was looking in Google and I don't find anything that solves my
doubt. Is there any way I can check if a variable is an file handler
of an opened file?.

perldoc -f fileno


John
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top