From: Jos I. Boumans [mailto:[EMAIL PROTECTED]
 
> Hi,
> 
> i was happily programming along, and in the course of events found the
> need to have
> an FH like interface, with a custom backend. I found that these two
> invocations, on
> the same object do not produce the same result:
> 
>       $obj->readline vs <$obj>
> 
> It only does what i expect in the former case, not the latter:
> 
>      sub X::readline { 1 };
>      $x = bless {}, 'X';
>      print "rl ". $x->readline . $/;
>      print "<> ". <$x> . $/;
>      rl 1
>      Not a GLOB reference at - line 4.
> 
> As it seems, it calls the builtin readline() on <>, rather than the
> class' readline():
> 
>      BEGIN { *CORE::GLOBAL::readline = sub { 2 }; }
>      sub X::readline { 1 };
>      $x = bless {}, 'X';
>      print "rl ". $x->readline . $/;
>      print "<> ". <$x> . $/;
>      rl 1
>      <> 2
> 
> This doens't seem to DWIM. And although i've now found how i can make
> happen what
> i want, it seems an inelegant solution at best.
> 
> Any thoughts?

You need a self-tie. Have a look at IO::String for a good example of how to
do it.

Paul


        
        
                
___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail 
http://uk.messenger.yahoo.com

Reply via email to