5 fields - compile-time class fields
11 use fields qw(foo bar baz);
14 my Foo $var = new Foo;
17 # This will generate a compile-time error.
22 The C<fields> pragma enables compile-time verified class fields.
28 my ($package) = caller;
29 my $fields = \%{"$package\::FIELDS"};
30 my $i = $fields->{__MAX__};
32 if (defined($fields->{$f})) {
34 Carp::croak("Field name $f already in use");
38 $fields->{__MAX__} = $i;