in reply to enforcing list context

I believe you could also do the following to always have list context on the comma:

sub value { my ($self) = @_; return ()=( $self->{first}, $self->{rest} ? $self->{rest}->value : () ); }

Replies are listed 'Best First'.
Re^2: enforcing list context
by japhy (Canon) on Apr 26, 2006 at 11:46 UTC
    But that won't return anything in list context! The other problem is that you need to call value() with the same context each recursive time. I think breaking it down via wantarray() is the simplest solution.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

      Ah, you're right. I was thinking that half a goatse op might do it, but that's what I get for thinking before my morning caffiene.