in reply to Inheritance and IO

This is an example for overloading the diamond operator:
use overload '<>' => sub { return shift @{shift()}; }; my $obj = bless [ "hello", "world" ]; while ( defined( my $line = <$obj> ) ) { print "it says: $line\n"; }
I suggest having a look at "perldoc overload" for more information.

Update: Expanded my example code

According to the documentation, using the overloaded operator in list context (as you intend to do) is not really supported.

Replies are listed 'Best First'.
Re^2: Inheritance and IO
by casiano (Pilgrim) on Jul 22, 2007 at 12:03 UTC
    Thank you very much for your advice. It works