in reply to Skipping parameters in sprintf %, elegantly

Array slicing, eg:

printf "l=%s p=%s f=%s", (caller)[2, 0, 1] ;

Replies are listed 'Best First'.
Re^2: Skipping parameters in sprintf %, elegantly
by jwkrahn (Abbot) on Aug 19, 2008 at 23:08 UTC

    (caller)[2, 0, 1] is a LIST SLICE not an array slice, there is no array there.

      I regret that the distinction between an ARRAY and a LIST in Perl is lost on me :-(. I humbly beg that you initiate me into this mystery.

        One way to think of it is that a list is a series of things (scalars) separated by commas while an array is a single variable that contains a list. Some would say (and have said) that an array is a list.

        An array in a scalar context will evaluate to the number of items in the array. A list in a scalar context evaluates to whatever the last item in the list would be in a scalar context, and the other items in the list receive a context that's, um, based on context (see Re^3: ||= oddity).

        Hope this helps.