holli has asked for the wisdom of the Perl Monks concerning the following question:
that gets used like so:package SomeClass; use overload '<>' => \⋄ sub diamond { my $self = shift; if ( wantarray ) { print "wants array\n"; return $self->handle->getlines; } else { print "wants scalar\n"; return $self->handle->getline; } } #... rest of code
The problem: In the diamond function wantarray allways returns false, even when the diamond operator is in list context (like in the code above).my $f = SomeClass->new ("somefile"); my @f = <$f>; #here I get only one line instead of all
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: overload and wantarray
by Corion (Patriarch) on Feb 08, 2006 at 09:51 UTC |