"Beau E. Cox" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi -
>
> I want to determine is a variable is a file handle.
>
> How would I do this?
>
> I know how to tell if it is a ref to something,
> but I can't seem to be able to find out if it
> is a file handle.
>

don't know what you mean but I will give it a try. you mean something like:

#!/usr/bin/perl -w

use strict;
use IO::File;

my $fh = new IO::File;

$fh->open("foo.txt") || die $!;

if(ref($fh) =~ /io::file/i){
    print "looks like IO::File object. I guess I will take it as a file
handle\n";
}else{
    print "Can be anything\n";
}

$fh->close;

#-- Or something like:

open(FILE,"foo.txt") || die $!;

my $t = *FILE;

if($t =~ /file/i){
    print "Again looks like a file handle\n";
}else{
    print "Can be anything\n";
}

close(FILE);

__END__

david



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to