Hi monks,
I thought about writing a module, which allows an easy way to alias perl built-in functions.
For example the bless function an evil monk would not want to use all day, but he might be happy to curse or damn the references.
use Acme::Alias bless => [qw(curse damn)]; my $string = "foo"; my $obj = curse \$string, 'CursedString'; my $obj2 = damn \$string, 'DamnedString';
My feeling is that that somewhere on CPAN a module with this functionality should exist. However I did not find it. Do you happen to know such a module?
Alternatively one could upload:
package Acme::Alias; use Filter::Simple; use strict; use warnings; our $VERSION = '0.01'; our %Symbols = (); sub import() { shift; my %all = @_; for (keys %all){ if ( ref($all{$_}) eq 'ARRAY'){ $Symbols{$_} = join q(|), @{$all{$_}}; } else { $Symbols{$_} = $all{$_} } } } FILTER_ONLY code => sub { while (my ($key,$val) = each %Symbols){ s/$val/$key/gs; } }; 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Aliasing built-in Functions
by rinceWind (Monsignor) on Mar 19, 2006 at 17:58 UTC | |
by xdg (Monsignor) on Mar 19, 2006 at 21:09 UTC | |
|
Re: Aliasing built-in Functions
by Fletch (Bishop) on Mar 19, 2006 at 16:20 UTC | |
|
Re: Aliasing built-in Functions
by graff (Chancellor) on Mar 19, 2006 at 23:31 UTC | |
by codeacrobat (Chaplain) on Mar 21, 2006 at 19:34 UTC | |
|
Re: Aliasing built-in Functions
by spiritway (Vicar) on Mar 19, 2006 at 18:05 UTC | |
by eric256 (Parson) on Mar 19, 2006 at 22:33 UTC | |
|
Re: Aliasing built-in Functions
by ambrus (Abbot) on Mar 19, 2006 at 21:47 UTC |