in reply to a few questions about __PACKAGE__

The error message you posted is on line 8, but the code you posted does not have 8 lines

The code you posted does not compile (typo)

You're also missing a pair of braces in the interpolation, to dereference the reference you're taking

The syntax you're looking for, the common idiom, is

print "@{[ 1,2,'Q', rand ]}\n"; print "@{[ __PACKAGE__ ]}\n"; __END__ 1 2 Q 0.770751953125 main

references quick reference

Replies are listed 'Best First'.
Re^2: a few questions about __PACKAGE__
by Anonymous Monk on Feb 11, 2012 at 15:36 UTC
    I think the form of that idiom the OP had seen was probably
    $ perl -wE 'print "${\__PACKAGE__}\n";'
    main
    (or "${\(...)}") which is a little less unsightly, if the expression returns a scalar.