in reply to Parameter list wierdness

Try writing your ternary operation like this:
sub test{ my $params; $params = ref($_[0]) ? shift : {@_}; print Dumper($params); }
Be well.

Replies are listed 'Best First'.
Re^2: Parameter list wierdness
by CassJ (Sexton) on Jul 01, 2004 at 15:39 UTC
    aah, that works and it's much nicer. Still think I'm missing something about how the ternary operator works though!

    Thanks, Cxx

      my $value = (if condition? then this: else this);
      That's about the quickest explanation. Ternary should never be used in void context. See my node Ternary in void context where I cleared up my ternary confusion as well. The ternary operator always returns the value present in its truth branch (for lack of a better term), that's why you shouldn't substitute it for if then constructs.

      an if then construct that warrants a ternary is similar to the following

      if($some_var eq 'X') { $this_var = 'Run using X format'; } else { $this_var = 'Run using standard format'; }
      This would equate to the ternary
      $this_var = ($some_var eq 'X'? 'Run using X format':'Run using standar +d format');