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
In reply to overload and wantarray by holli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |