in reply to Problem with parameters in subroutines
Others have already answered your more immediate question, but from the way you asked, it looks like you may have a misconception about how subroutine parameters work in the first place.
All that passing parameters to a subroutine call does, is to make those values available to the subroutine in the special @_ array.
It does not automatically make each parameter a variable inside the subroutine, and in fact it won't have any effect at all if the subroutine does not choose to look at the contents of @_.
Often, "looking at the contents of @_" is done implicitly using calls to shift, hence the my $candidate = shift; in the above answer.
If you need more explanation, please read perlintro#Writing-subroutines.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem with parameters in subroutines
by aatrox (Initiate) on Jun 02, 2014 at 14:05 UTC | |
by smls (Friar) on Jun 02, 2014 at 14:30 UTC | |
by taint (Chaplain) on Jun 02, 2014 at 14:46 UTC |