in reply to @_ the default variable?

@_ is only passed unchanged to functions called using a prefixing & and no () (e.g. &func). However shift is not really a function. That means you cannot call it like &shift. Shift also takes its arguments in a special way so the & syntax would not even make sense, because & ignores prototypes (which are needed to obtain this "special" treatment of arguments from perl code.)

arturo is mostly correct about what shift defaults to, but note that there are exceptions (that you are unlikely to encounter anytime soon) where shift will take @ARGV by default within a subroutine. See the docs for more details.

Replies are listed 'Best First'.
Re: Re: @_ the default variable?
by Anonymous Monk on Sep 14, 2001 at 22:50 UTC
    If shift "is not really a function", what is it? And I thought only *subroutines* were called with &. shift certainly isn't a subroutine.
      The words subroutine and function are often used interchangably in perl. (Even perlsub does it!) What I meant by calling shift "not really a function" was that it is very unlike the functions you define in your code, which have a symbol table entry and thus are associated with a package, can have coderefs be taken of them, and be aliased to other names at the symbol table entry, or imported into other packages, in addition to being callable by the & syntax.
        You mean you can't override shift like you can with other built-in functions (import into CORE:: if memory serves)?