in reply to shift vs @_
This question is discussed at length in the excellent Perl Best Practices book in the third item of Chapter 9, "Argument Lists: Always unpack @_ first". Notice that this chapter is available free online as the book's sample chapter.
In this item, TheDamian argues that either version is acceptable, with the shift-based version preferred when one or more arguments needs to be sanity checked or documented with a trailing comment. The most important thing though, is to unpack them at the start of the subroutine and to avoid accessing them directly as $_[0], $_[1] etc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: shift vs @_
by shmem (Chancellor) on Oct 02, 2006 at 23:15 UTC |