in reply to Re: Several stupid questions about subs
in thread Several stupid questions about subs

my @digitsOfPi = (3,1,4,1,5,9,2,6,5,3,5,9,'etc'); frobnicate('foo', 'bar', @digitsOfPi); sub frobnicate { my $fooString = shift; my $barString = shift @_; #more typing my @remainder = @_; print $remainder[0] == 3 ? 'yum' :'eew'; }

Replies are listed 'Best First'.
Re^3: Several stupid questions about subs
by ikegami (Patriarch) on Apr 13, 2011 at 17:48 UTC

    my (...) = @_; is a very common way of getting args. I can't believe it wasn't mentioned.

    sub frobnicate { my ($foo, $bar, @remainder) = @_; print $remainder[0] == 3 ? 'yum' :'eew'; }
      Probably because the OP was asking about getting variables from the sub back to the scope from which it was called and this is the other way around.

      That code was in reply to the reply asking what my $var = shift; is all about