On 1 Mar 2002, Randal L. Schwartz wrote:

> sub is_filehandle_or_symbolic_handle {
>   not ref $_[0] # symref
>   or UNIVERSAL::isa($_[0], "IO::Handle");
> }
> 
> sub is_strictly_filehandle {
>   ref $_[0] # not string
>   and UNIVERSAL::isa($_[0], "IO::Handle");
> }
> 
> I think that's a lot easier to understand than your mess.
 
Sorry, you've lost me.  Running is_strictly_filehandle though the 
testsuite I previously had from my routine gives me:

ok 1 - undef not a file handle
ok 2 - scalar not a file handle
not ok 3 - ref to a glob that's a filehandle
#     Failed test (filehandle.pl at line 19)
ok 4 - ref to a glob that's not a filehandle
ok 5 - Any class
ok 6 - ref to a typeglob
ok 7 - Even if it's a gensym
not ok 8 - io file a non opened filehandle
#     Failed test (filehandle.pl at line 47)
ok 9 - io file a open filehandle
ok 10 - File Temp File
not ok 11 - tied handle
#     Failed test (filehandle.pl at line 73)
ok 12 - tied hash
ok 13 - IO::Scalar # TODO Maybe IO::Scalar isn't a filehandle
1..13
# Looks like you failed 3 tests of 13.

To remphasise, the tests that fail are:

###

open FOO, ">foo"
 or die "Can't open 'foo': $!";
ok(filehandle(\*FOO),"ref to a glob that's a filehandle");

###

use IO::File;
$fh = IO::File->new();
ok(!filehandle($fh), "io file a non opened filehandle");

###

package Tie::MyHandle;
sub TIEHANDLE { return bless {}, $_[0]}
package main;

tie *WOBBLE, "Tie::MyHandle";
ok(filehandle(\*WOBBLE), "tied handle");

###

Later.

Mark. 

-- 
s''  Mark Fowler                                     London.pm   Bath.pm
     http://www.twoshortplanks.com/              [EMAIL PROTECTED]
';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/  +/
){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}


Reply via email to