in reply to Re: trouble understanding code, and shift() w.o args
in thread trouble understanding code, and shift() w.o args

okay this definately helped, :-) but what if i want an additional filepath as one of the arguments in the subroutine? would it be somethin like this?
$ret_value = getXCharacterPatterns($var1, $var2, $filepath2);
wow, u have no idea how much that helped, thx a lot

Replies are listed 'Best First'.
Re^3: trouble understanding code, and shift() w.o args
by GotToBTru (Prior) on Aug 04, 2011 at 16:47 UTC

    Yes, that's how you'd add a third argument. You would need to also add a third shift in the subroutine to use it.

    Perl's handling of parameters to subroutines is strange; every other language I have used requires the parameters be listed in the subroutine definition. I have often seen

    sub translate { my ($noun, $verb, $object) = @_; my $german = "$noun $object $verb"; return($german); }

    in order to document what the subroutine expects: 1) three arguments, 2) in the order noun, verb, object. Also, that would be less confusing to a novice Perl programmer because it explicitly names @_, instead of assuming you know about it. Which, of course, now you do.