On Mon, Nov 10, 2008 at 09:52, Travis Thornhill
<[EMAIL PROTECTED]> wrote:
> Is there such a thing?
>
> I'm trying to take a HoH and make a reference to a sub-part of the hash.
>
> This doesn't work:
>
> my %sub_hash = $main_hash{'sub_hash'};
>
> I get the following error:
> Reference found where even-sized list expected at ./my_buggy_program line 30.
>
> Any quick tips on how to reference and assign this sub-hash?
snip

#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my %name_to_num = (
        one   => 1,
        two   => 2,
        three => 3,
        four  => 4,
        five  => 5,
        six   => 6
);

#get keys whose values are odd
my @keys = grep { $name_to_num{$_} % 2 } keys %name_to_num;

#make a hash of the odd keys and values with a hash slice
my %odd_name_to_num;
@[EMAIL PROTECTED] = @[EMAIL PROTECTED];

print Dumper \%name_to_num, \%odd_name_to_num;


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to