How can I tell if a variable is a FileHandle?

Discussion in 'Perl Misc' started by peterkayatwork@yahoo.com, Jan 11, 2005.

  1. Guest

    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
    , Jan 11, 2005
    #1
    1. Advertising

  2. Anno Siegel Guest

    <> wrote in comp.lang.perl.misc:
    > 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
    Anno Siegel, Jan 11, 2005
    #2
    1. Advertising

  3. Guest

    <blushes bring pink>

    Thanks!
    , Jan 13, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yogesh
    Replies:
    1
    Views:
    353
    Victor Bazarov
    Mar 14, 2007
  2. mathias

    filehandle to variable problem

    mathias, Jul 15, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    91
    mathias
    Jul 17, 2003
  3. Mike A
    Replies:
    17
    Views:
    247
    Dr John Stockton
    Nov 19, 2003
  4. Sniff
    Replies:
    6
    Views:
    129
    Uri Guttman
    Dec 21, 2007
  5. PerlFAQ Server
    Replies:
    0
    Views:
    120
    PerlFAQ Server
    Apr 6, 2011
Loading...

Share This Page