1Damn(3) User Contributed Perl Documentation Damn(3)
2
3
4
6 Acme::Damn - 'Unbless' Perl objects.
7
9 use Acme::Damn;
10
11 my $ref = ... some reference ...
12 my $obj = bless $ref , 'Some::Class';
13
14 ... do something with your object ...
15
16 $ref = damn $obj; # recover the original reference (unblessed)
17
18 ... neither $ref nor $obj are Some::Class objects ...
19
21 Acme::Damn provides a single routine, damn(), which takes a blessed
22 reference (a Perl object), and unblesses it, to return the original
23 reference. I can't think of any reason why you might want to do this,
24 but just because it's of no use doesn't mean that you shouldn't be able
25 to do it.
26
27 EXPORT
28 By default, Acme::Damn exports the method damn() into the current
29 namespace. Aliases for damn() (see below) may be imported upon request.
30
31 Methods
32 damn object
33 damn() accepts a single blessed reference as its argument, and
34 returns that reference unblessed. If object is not a blessed
35 reference, then damn() will "die" with an error.
36
37 Method Aliases
38 Not everyone likes to damn the same way or in the same language, so
39 Acme::Damn offers the ability to specify any alias on import, provided
40 that alias is a valid Perl subroutine name (i.e. all characters match
41 "\w").
42
43 use Acme::Damn qw( unbless );
44 use Acme::Damn qw( foo );
45 use Acme::Damn qw( unblessthyself );
46 use Acme::Damn qw( recant );
47
48 Version 0.02 supported a defined list of aliases, and this has been
49 replaced in v0.03 by the ability to import any alias for "damn()".
50
52 Just as "bless" doesn't call an object's initialisation code, "damn"
53 doesn't invoke an object's "DESTROY" method. For objects that need to
54 be "DESTROY"ed, either don't "damn" them, or call "DESTROY" before
55 judgement is passed.
56
58 Thanks to Claes Jacobsson <claes@surfar.nu> for suggesting the use of
59 aliases.
60
62 bless, perlboot, perltoot, perltooc, perlbot, perlobj.
63
65 Ian Brayshaw, <ian@onemore.org>
66
68 Copyright 2003-2006 Ian Brayshaw
69
70 This library is free software; you can redistribute it and/or modify it
71 under the same terms as Perl itself.
72
73
74
75perl v5.12.0 2009-05-15 Damn(3)