<banzi>Bet now! Bet now!</banzi>

How do I determine if something passed to me is a filehandle or something
containing the name of the file to open.  This *should* be fairly simple,
but I can't work out a simple way to do it.

Attempts:

   ref($foo) eq "GLOB" 

     works fine for plain globs, fails on IO::Handle

   use Scalar::Util qw(reftype);
   reftype($foo) eq "GLOB"

     works fine for blessed filehandle globs.  Fails on object that are 
     based on globs that arn't filehandles.  Most notably those that 
     have overloaded stringification that we're expecting to be able to
     use as a filename.

   use Scalar::Util qw(reftype blessed);
   reftype($foo) eq "GLOB" && blessed($foo) && $foo->isa("IO::Handle");

     Avoids false positives on blessed globs that arn't IO::Handles but
     now doesn't work with "I just rolled my own glob wrapper that isn't
     an IO::Handle".

Have I overlooked something obvious?  Or is this perl being annoying?

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