in reply to Re^5: Line numbers
in thread Line numbers

> is expanding to:

> say $package, $filename, $line, $subroutine, $hasargs,$wantarray, $evaltext, $is +_require, $hints, $bitmask, $hinthash,[0];

nope, and you're showing valid code! After the last comma comes a literal arrayref [0].

DB<100> print $a,[0]; ARRAY(0x84e16b8)

the syntax-error comes from appending [0] unseparated to a function call say().

and nothing is "expanded" at parsing time.

Cheers Rolf

Replies are listed 'Best First'.
Re^7: Line numbers
by gg48gg (Sexton) on Mar 19, 2012 at 17:42 UTC

    Thanks for setting me straight Rolf. I was getting an error because I didn't have the say feature enabled. I guess I shouldn't have stated it so matter-of-fact. I was so sure I had it figured out.

    I am still a little confused about this and why anonymous' code works...

    print '', (caller(0))[0];

    and why this gets a syntax error:

    print (caller(0))[0];
      Because parens around sub-args are optional.

      print '', (caller(0))[0]; means print ( '', (caller(0))[0] );

      But providing explicit parens after a sub-name will disable automatic grouping of args.

      Cheers Rolf

        Ahhh, I think I understand. That is why this does work, right?

        print ((caller(0))[0]);