in reply to What CODE typeglob slot is my anonymous sub in?
Your use of uc is what is causing your problem I think:
#! perl -slw use strict; my @types = qw( date integer text timestamp ); foreach my $type (@types) { my $function = uc $type; no strict 'refs'; *$function = sub { # line 1 "$type.anon" if ( looks_like_number( $_[0] ) ) { die "Datatype '$type' does not require a numeric length '$ +_[0]'"; } return { type => $type, @_ }; }; print *$function; } __END__ C:\test>junk6 *main::DATE *main::INTEGER *main::TEXT *main::TIMESTAMP
Remove it and you get:
C:\test>junk6 *main::date *main::integer *main::text *main::timestamp
Is that what you are after?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What CODE typeglob slot is my anonymous sub in?
by Ovid (Cardinal) on Apr 24, 2007 at 10:26 UTC |