Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Is there a simple syntax to logically slice a hash?

by tobyink (Canon)
on Feb 21, 2013 at 15:42 UTC ( [id://1019966]=note: print w/replies, xml ) Need Help??


in reply to Is there a simple syntax to logically slice a hash?

Something like this?

use strict; use warnings; use Data::Dumper; my %orig = ( cat => 22, dog => 23, category => 66, catalyst => 77, cataclysm => 88, dogma => 89, dogstar => 92, ); my %cats_only = map { $_ => $orig{$_} } grep /^cat/, keys %orig; print Dumper \%cats_only;
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-23 18:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found