#! 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 #### C:\test>junk6 *main::date *main::integer *main::text *main::timestamp