Mark Jason Dominus gave a talk about the life and death of pseudohashes. (I’d heard of them but had no idea what they actually were before seeing this video.)

I infer from it that fields.pm originated as a convenient interface for pseudohashes and that after they went away fields.pm was kept around mainly for backwards compatibility and reworked to use restricted hashes.

I’d never played with fields.pm before, but I spent a few minutes with it just now and I can guess why it’s not very popular: it doesn't make much of an object. It doesn’t auto-generate accessors or a constructor. (Code is pasted below.) The attempted method call $blurple->blue blows up because there's no blue method. Also, the copy of %params into %{$self} will blow up if you pass any parameter name other than "red", "green", or "blue".

#!/usr/bin/perl package RGBColor { use fields qw(red green blue); sub new { my RGBColor $self = shift; my %params = @_; unless (ref $self) { $self = fields::new($self); } %{$self} = %params; return $self; } } my $blurple = RGBColor->new(red => 75, blue => 200, green => 0); print "blurple's blue is $blurple->{blue}\n"; print "blurple's blue is " . $blurple->blue ."\n"; # kaboom, no such +method
– Aaron
Preliminary operational tests were inconclusive. (The damn thing blew up.)

In reply to Re^3: do separate hashes share common keys? by Radiola
in thread do separate hashes share common keys? by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.