#!/usr/bin/perl use strict; use warnings; use Devel::Peek; my @types = qw( text ); foreach my $type (@types) { my $function = uc $type; my $type_sub; no strict 'refs'; $type_sub = \&$function; *$type = sub { warn "subtype: ",shift,"\n"; warn "args: @_\n"; warn "typeglob slot: ",Devel::Peek::CvGV($type_sub),"\n"; }; *$function = sub { &{$type}($function,@_); }; } sub alias { my ($target, $source) = @_; no strict 'refs'; *$target = sub { \&{lc $source}(lc $target,@_) }; } alias("TINYTEXT","TEXT"); TINYTEXT(3); *text = sub { warn "wuff! @_\n" }; TINYTEXT("which spake the blue_cowdawg."); __END__ subtype: tinytext args: 3 typeglob slot: *main::TEXT Subroutine main::text redefined at ovid.pl line 36. wuff! tinytext which spake the blue_cowdawg.