diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fields.pm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/fields.pm b/lib/fields.pm new file mode 100644 index 0000000000..8e2d6398bb --- /dev/null +++ b/lib/fields.pm @@ -0,0 +1,18 @@ +package fields; + +sub import { + my $class = shift; + my ($package) = caller; + my $fields = \%{"$package\::FIELDS"}; + my $i = $fields->{__MAX__}; + foreach my $f (@_) { + if (defined($fields->{$f})) { + require Carp; + Carp::croak("Field name $f already in use"); + } + $fields->{$f} = ++$i; + } + $fields->{__MAX__} = $i; +} + +1; |