use Data::Dumper; local ($,, $\) = (' ', "\n"); # Create a pseudo hash my $ph = new PseudoHash(qw/FOO BAR BAZ/); # Assign and read existing fields $ph->field('FOO') = 42; print 'FOO:', $ph->field('FOO'); $ph->field('BAR') = 23; print 'BAR:', $ph->field('BAR'); # Create a pseudo hash with identical structure as $ph my $pi = $ph->new(); # Assign and read an existing field $pi->field('BAR') = 23; print 'BAR:', $pi->field('BAR'); # Create a pseudo hash with structure based on $ph my $pj = $ph->new(qw/QUARK/); # Assign and read an existing field $pj->field('QUARK') = 'Hallo'; print 'QUARK:', $pj->field('QUARK'); # Show the structure of the pseudo hashes print Dumper [ $ph, $pi, $pj ]; # Try to access a non-existing field $ph->field('BOING'); # generates an error