Gunnar Hjalmarsson wrote:
Chas. Owens wrote:
On Sat, Mar 22, 2008 at 11:53 PM, Richard Lee <[EMAIL PROTECTED]> wrote:
snip
@{ $HoH{$1} }{ @{ $HoA{$1} } } = split;

This is really spinning my heads in all direction trying to see if I can
truly understand them instead of just using it.
snip

Take a look at

http://perldoc.perl.org/perldata.html#Slices

and

http://perldoc.perl.org/perlref.html

Absolutely.

What's happening is that we assign what's returned from split() to a hash slice.

    @hash{ @keys_list } = split;

The hash in this case is one of the anonymous hashes in %HoH. The reference to it, $HoH{$1}, needs to be dereferenced.

    @{ $HoH{$1} }{ @keys_list } = split;
----^^^^^^^^^^^^^

The keys_list is one of the anonymous arrays in %HoA. The reference to it, $HoA{$1}, needs to be dereferenced as well.

    @{ $HoH{$1} }{ @{ $HoA{$1} } } = split;
-------------------^^^^^^^^^^^^^



say I have @data which below was pushed(bunch of them) with below hash of hash refernce

$VAR1 = {
         'element' => {
                                 'element2' => 'now',
                                 'element3' => '2',
                                 'element4' => 'serverxxx',
                               }
               };

and then I would call sub do_it like
do_it(somevalue, $data)

sub do_it {
my $something = shift;
    for (@_) {
      foreach my $XX ( keys %_ ) {
if ( exists ( $XX->{ element }{ element2 } ) && $XX->{ element }{ element4} eq "$something" ) { for my $key ( keys %{ $XX{ element } } ) { <------ Global symbol "%XX" requires explicit package name <--------------------?????
                print "$key\n";
                print "$XX and $XX{ element}{$key}\n";
           }
        }
       }
}

why does it not like XX in above line ??

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


Reply via email to