use overload '<>' => sub { return shift @{shift()}; }; my $obj = bless [ "hello", "world" ]; while ( defined( my $line = <$obj> ) ) { print "it says: $line\n"; }