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

Re: Slicing a hash reference from a collection of hash references within a hash

by stevieb (Canon)
on Oct 07, 2015 at 15:35 UTC ( #1144072=note: print w/replies, xml ) Need Help??


in reply to Slicing a hash reference from a collection of hash references within a hash reference

First thing is, use strict; and use warnings;. There are syntax errors in the code you specified.

Here's one way to extract out the hash slice you need...

use warnings; use strict; my $household = { 23 => { last => 'Smith', first => 'Mary' }, 22 => { last => 'Jones', first => 'Bob' }, }; my $name = join ' ', @{ $household->{23} }{'first', 'last'};

-stevieb

Replies are listed 'Best First'.
Re^2: Slicing a hash reference from a collection of hash references within a hash
by nysus (Parson) on Oct 07, 2015 at 15:40 UTC
    Thank you! Looks so damn obvious once you see the solution.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon";
    $nysus = $PM . $MCF;
    Click here if you love Perl Monks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1144072]
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 2021-05-07 23:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (95 votes). Check out past polls.

    Notices?