Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
i found this in a CPAN module :
{ my $singleton = bless \my($x), __PACKAGE__; sub new { return $singleton } sub AUTOLOAD { return $singleton } sub can { return sub { return $singleton } } }
what is the first stmt doing? its' a blessing of something to the current package.
but the $x is NOT declared anywhere in the package. and i don't understand what a reference of the my keyword does?
using Data::Dumper, i get this :
bless ( do{ \( my $o = undef ) }, 'package_name' )
feel free to point me to any documentation. thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: syntax question
by moritz (Cardinal) on Sep 21, 2010 at 07:33 UTC | |
|
Re: syntax question
by JavaFan (Canon) on Sep 21, 2010 at 07:34 UTC | |
|
Re: syntax question
by GrandFather (Saint) on Sep 21, 2010 at 07:48 UTC | |
by JavaFan (Canon) on Sep 21, 2010 at 09:46 UTC | |
|
Re: syntax question
by locked_user sundialsvc4 (Abbot) on Sep 21, 2010 at 12:57 UTC | |
|
Re: syntax question
by Anonymous Monk on Sep 21, 2010 at 07:28 UTC | |
|
Re: syntax question
by jakeease (Friar) on Sep 21, 2010 at 18:08 UTC |