When you start doing this, I think one of the most striking thing is just how many WTDI (Ways To Do It - from TMTOWTDI) some modules employ. Some of my favourites are
while (<DATA>) { # get a line of POD if (/^=item\s+(LDAP_\S+)\s+\((.*)\)/) {# look for a POD line of =ite +m LDAP_<constant> (<value>) $const{$name} = sub () { $value }; # set the constant from what wa +s in the POD !!! } }
sub fake_module { my ($class, $modname, %subs) = @_; # replace methods in $modn +ame with those in %subs $INC{ $modname . '.pm' } = 1; # pretend we have already loaded + the module foreach my $sub (keys %subs) { # for each implementation provi +ded ... *{ $module . '::' . $sub } = $subs{ $sub }; # store th +e provided implementation in the symbol table } }
Those are just three recent ones where I suddenly stopped reading, sat up and went 'Thats ... incredible'.
Perhaps other monks would care to share the wonderful ideas (and weird ones too ... ) held in CPAN.
use brain;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Interesting WTDI
by nimdokk (Vicar) on Nov 09, 2004 at 12:50 UTC | |
by itub (Priest) on Nov 09, 2004 at 14:34 UTC | |
by nimdokk (Vicar) on Nov 09, 2004 at 14:36 UTC | |
|
Re: Interesting WTDI
by monoxide (Beadle) on Nov 09, 2004 at 22:22 UTC | |
by Jenda (Abbot) on Nov 09, 2004 at 22:57 UTC | |
by chromatic (Archbishop) on Nov 10, 2004 at 04:21 UTC |