To know if a variable is a file handler

Discussion in 'Perl Misc' started by Luis Angel Fdez. Fdez., Jul 19, 2007.

  1. 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!
     
    Luis Angel Fdez. Fdez., Jul 19, 2007
    #1
    1. Advertising

  2. Luis Angel Fdez. Fdez.

    Sisyphus Guest

    "Luis Angel Fdez. Fdez." <> wrote in message
    news:...
    > 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
     
    Sisyphus, Jul 19, 2007
    #2
    1. Advertising

  3. Luis Angel Fdez. Fdez. wrote:
    >
    > 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
    --
    Perl isn't a toolbox, but a small machine shop where you
    can special-order certain sorts of tools at low cost and
    in short order. -- Larry Wall
     
    John W. Krahn, Jul 19, 2007
    #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. shruds
    Replies:
    1
    Views:
    836
    John C. Bollinger
    Jan 27, 2006
  2. Replies:
    1
    Views:
    708
    Damien
    Feb 22, 2007
  3. Replies:
    0
    Views:
    357
  4. northof40
    Replies:
    3
    Views:
    210
    Nathan Sokalski
    Nov 2, 2007
  5. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    240
    Gregory Toomey
    Apr 23, 2004
Loading...

Share This Page