in reply to (Ovid) Re(2): Syntax for preventing repeat object initializations
in thread Syntax for preventing repeat object initializations

The "unary +" fix is shorter...
$foo->{+__PACKAGE__} = 1;
Hmm, patching a book isn't quite so easy!

_____________________________________________________
Jeff japhy Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

  • Comment on Re: (Ovid) Re(2): Syntax for preventing repeat object initializations
  • Download Code

Replies are listed 'Best First'.
Re: Re: (Ovid) Re(2): Syntax for preventing repeat object initializations
by MeowChow (Vicar) on Jul 17, 2001 at 05:37 UTC
    I was toying around with __PACKAGE__ just yesterday. For interpolation into strings, you can do the scalar ref-deref trick:
    my $str = "I'm in package ${\__PACKAGE__}"
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print