in reply to Re^2: Printing accessor methods in here documents
in thread Printing accessor methods in here documents

Similarly, if you'd wanted $self->blat() evaluated in scalar context, you could say ${\$self->blat()}.

(Added) !1++, you're exactly right.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^4: Printing accessor methods in here documents
by !1 (Hermit) on May 06, 2005 at 21:37 UTC

    Uh, not exactly. It actually evaluates in list context but treats the return as if it were in scalar. Like so:

    #!/usr/bin/perl -wl my @x = qw[ a b c d ]; sub x { print wantarray ? "list context" : defined(wantarray) ? "scalar context" : "void context"; @x } print "@{[ x() ]} - ${\ ( x() )} - ${\ ( @x )}"; __END__ list context list context a b c d - d - d