| 1 |
NAME |
| 2 |
Acme::Damn - 'Unbless' Perl objects. |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
use Acme::Damn; |
| 6 |
|
| 7 |
my $ref = ... some reference ... |
| 8 |
my $obj = bless $ref , 'Some::Class'; |
| 9 |
|
| 10 |
... do something with your object ... |
| 11 |
|
| 12 |
$ref = damn $obj; # recover the original reference (unblessed) |
| 13 |
|
| 14 |
... neither $ref nor $obj are Some::Class objects ... |
| 15 |
|
| 16 |
INSTALLATION |
| 17 |
To install this module type the following: |
| 18 |
|
| 19 |
perl Makefile.PL |
| 20 |
make |
| 21 |
make test |
| 22 |
make install |
| 23 |
|
| 24 |
Acme::Damn uses XS to access the internals of Perl for it's magic, and |
| 25 |
therefore must be compiled to be installed. Also, for testing, |
| 26 |
Acme::Damn relies on Test::More and Test::Exception. |
| 27 |
|
| 28 |
DESCRIPTION |
| 29 |
Acme::Damn provides a single routine, damn(), which takes a blessed |
| 30 |
reference (a Perl object), and *unblesses* it, to return the original |
| 31 |
reference. |
| 32 |
|
| 33 |
EXPORT |
| 34 |
By default, Acme::Damn exports the method damn() into the current |
| 35 |
namespace. Aliases for damn() (see below) may be imported upon request. |
| 36 |
|
| 37 |
Methods |
| 38 |
damn *object* |
| 39 |
damn() accepts a single blessed reference as its argument, and |
| 40 |
returns that reference unblessed. If *object* is not a blessed |
| 41 |
reference, then damn() will "die" with an error. |
| 42 |
|
| 43 |
bless *reference* |
| 44 |
bless *reference* [ , *package* ] |
| 45 |
bless *reference* [ , undef ] |
| 46 |
Optionally, Acme::Damn will modify the behaviour of "bless" to allow |
| 47 |
the passing of an explicit "undef" as the target package to invoke |
| 48 |
damn(): |
| 49 |
|
| 50 |
use Acme::Damn qw( bless ); |
| 51 |
|
| 52 |
my $obj = ... some blessed reference ...; |
| 53 |
|
| 54 |
# the following statements are equivalent |
| 55 |
my $ref = bless $obj , undef; |
| 56 |
my $ref = damn $obj; |
| 57 |
|
| 58 |
NOTE: The modification of "bless" is lexically scoped to the current |
| 59 |
package, and is *not* global. |
| 60 |
|
| 61 |
Method Aliases |
| 62 |
Not everyone likes to damn the same way or in the same language, so |
| 63 |
Acme::Damn offers the ability to specify any alias on import, provided |
| 64 |
that alias is a valid Perl subroutine name (i.e. all characters match |
| 65 |
"\w"). |
| 66 |
|
| 67 |
use Acme::Damn qw( unbless ); |
| 68 |
use Acme::Damn qw( foo ); |
| 69 |
use Acme::Damn qw( unblessthyself ); |
| 70 |
use Acme::Damn qw( recant ); |
| 71 |
|
| 72 |
Version 0.02 supported a defined list of aliases, and this has been |
| 73 |
replaced in v0.03 by the ability to import any alias for "damn()". |
| 74 |
|
| 75 |
WARNING |
| 76 |
Just as "bless" doesn't call an object's initialisation code, "damn" |
| 77 |
doesn't invoke an object's "DESTROY" method. For objects that need to be |
| 78 |
"DESTROY"ed, either don't "damn" them, or call "DESTROY" before |
| 79 |
judgement is passed. |
| 80 |
|
| 81 |
ACKNOWLEDGEMENTS |
| 82 |
Thanks to Claes Jacobsson <[email protected]> for suggesting the use of |
| 83 |
aliases, and Bo Lindbergh <[email protected]> for the suggested modification |
| 84 |
of "bless". |
| 85 |
|
| 86 |
SEE ALSO |
| 87 |
bless, perlboot, perltoot, perltooc, perlbot, perlobj. |
| 88 |
|
| 89 |
AUTHOR |
| 90 |
Ian Brayshaw, <[email protected]> |
| 91 |
|
| 92 |
COPYRIGHT AND LICENSE |
| 93 |
Copyright 2003-2016 Ian Brayshaw |
| 94 |
|
| 95 |
This library is free software; you can redistribute it and/or modify it |
| 96 |
under the same terms as Perl itself. |