in reply to Precendence and wantarray puzzling me

You really want || there as the = binds tighter than the or e.g
perl -MO=Deparse - my @things = $q->param('t') or $q->param('things'); my @things = $q->param('t') || $q->param('things'); ^D $q->param('things') unless my(@things) = $q->param('t'); my(@things) = $q->param('t') || $q->param('things');
Your best option for conditionally assigning lists is the ternary conditional operator e.g
my @things = $q->param('t') ? $q->param('t') : $q->param('things');
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Precendence and wantarray puzzling me
by ViceRaid (Chaplain) on Mar 04, 2004 at 15:57 UTC

    Ah, thanks all. I was put off by the fact that:

    my @things = $q->param('t') || $q->param('things');

    didn't DWIM, as the || puts each method call in scalar context. As an aside, how could one force list context for the evaluation of each of those method calls? With my imaginary list counterpart to scalar:

    my @things = list($q->param('t')) || list($q->param('things'));
      It can't be done (forcing list context with || that is), hence the ?: suggestion.
      HTH

      _________
      broquaint