Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: constraining the keys of a HashRef in Moose

by Your Mother (Bishop)
on Aug 29, 2013 at 23:04 UTC ( #1051524=note: print w/replies, xml ) Need Help??

in reply to Re: constraining the keys of a HashRef in Moose
in thread constraining the keys of a HashRef in Moose

PS: this is my 2000th post to PerlMonks!

Congratulations. We are lucky to count you among us, IMO, YMMV, IIRC, TIMTOWTDI, IANAL, etc. Took me 10 years. Not jealous though. Not a bit. You deserve the success. And sports cars and fancy desserts and nice clothes and emu farms and everything else I ever wanted that you’ve beaten me at^H^H to… I'm just going to go in the other room and chop onions for a bit.

  • Comment on Re^2: constraining the keys of a HashRef in Moose

Replies are listed 'Best First'.
Re^3: constraining the keys of a HashRef in Moose
by tomgracey (Beadle) on Aug 30, 2013 at 08:03 UTC

    Thanks kennethk and tobyink - really helpful.

    kennethk: I did think of making the hash into an object as per your first suggestion, but this would mean creating a large number of new packages (I think! The real situation is more complex than the simplified example). Using Hash::Utils is a very good idea though - this does what I need perfectly.

    tobyink: nice - this is the kind of Moosey thing I had in mind in the first place. There seem a great many packages which *might* be relevant (to me starting out at least) so its very helpful to know which someone experienced would pick. Congratulations on your 2000th post!

      It could mean a large number of new packages, but that doesn't necessarily mean a large number of new files. If I have a type that is only going to appear once as the field value of another type, I will frequently put the object declaration, a.k.a. the package, in the same file. This avoids the type of file proliferation you are concerned about, while still leveraging the full power of the Moose type system.

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1051524]
[Eily]: choroba but does $name = $1 solve the issue ?
[Eily]: if so, most subs start with my (VARIABLES) = @_ anyway
[moritz]: for short subs, I sometimes let them work on $_[0] directly
[Eily]: moritz but that should be fine unless you modify them

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2018-02-22 17:24 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (296 votes). Check out past polls.