/usr/share/doc/libhash-fieldhash-perl/examples/namedfields.pl is in libhash-fieldhash-perl 0.14-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #!/usr/bin/perl -w
use strict;
package MyClass;
use Hash::FieldHash qw(:all);
fieldhash my %foo => 'foo';
sub new{
my $class = shift;
my $self = bless {}, $class;
return from_hash($self, @_);
}
package MyDerivedClass;
use parent -norequire => 'MyClass';
use Hash::FieldHash qw(:all);
fieldhash my %bar => 'bar';
package main;
my $o = MyDerivedClass->new(foo => 10, bar => 20);
my $p = MyDerivedClass->new('MyClass::foo' => 10, 'MyDerivedClass::bar' => 20);
use Data::Dumper;
print Dumper($o->to_hash());
# $VAR1 = { foo => 10, bar => 20 }
print Dumper($o->to_hash(-fully_qualify));
# $VAR1 = { 'MyClass::foo' => 10, 'MyDerived::bar' => 20 }
|