Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Converting Hashes to Objects

by jo37 (Pilgrim)
on May 17, 2020 at 13:46 UTC ( #11116852=note: print w/replies, xml ) Need Help??


in reply to Converting Hashes to Objects

I like the idea, but dislike the name. H2O is water and nothing else :-)
Maybe Ohash or Shash (smart hash)?

Should have keys, values and each, too.

EDIT: At a second thought, this would prevent "keys", "values" and "each" as keys :-(
Not so good.

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Replies are listed 'Best First'.
Re^2: Converting Hashes to Objects
by haukex (Bishop) on May 17, 2020 at 14:07 UTC
    I like the idea, but dislike the name. H2O is water and nothing else :-)

    I like the name, at the moment I don't think I'll change it ;-)

    The objects are still hashrefs, you can still do keys %$hash etc.

      Maybe something for the perldoc: keys must be valid Perl identifiers if accessed via this module.

      Greetings,
      -jo

      $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
        keys must be valid Perl identifiers if accessed via this module.

        Good point, thanks, done.

        Other methods can still be called with trickery, but of course that's not really the point of this module :-)

        use Util::H2O; my $o = h2o { '$%@.?' => 123 }; my $meth = '$%@.?'; print $o->$meth; # prints 123
Re^2: Converting Hashes to Objects
by dsheroh (Monsignor) on May 18, 2020 at 09:21 UTC
    I like the idea, but dislike the name. H2O is water
    Yes, but if you're just taking a hash and autogenerating accessors for the hash elements, I'd say that's a pretty watered-down object.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11116852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2020-09-26 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (141 votes). Check out past polls.

    Notices?