Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

constraining the keys of a HashRef in Moose

by tomgracey (Scribe)
on Aug 29, 2013 at 14:48 UTC ( [id://1051451]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    ...
    has scores => ( is => 'rw', isa => 'HashRef[colors]', default => sub{{
    +}} ); # I want the allowed *keys* to be colors
    
    1;
    
  2. or download this
    #!/usr/bin/perl
    
    ...
    $hk->scores->{'black'} = 100;
    $hk->scores->{1} = 'blue';
    $hk->scores->{2} = 'dinosaur';
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1051451]
Approved by hdb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-03-28 23:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found