Re: Stuff a hash from two source files



In article <87hcwq8xx5.fsf@xxxxxxxxxxxxxxxxx>,
Alan_C <mtbr0228AT@xxxxxxxxxxxxxxxx> wrote:


$data{$box}{prior} = $prior; #??
This is called a hash of hashes (HOH). The perldoc's perlreftut and
perldsc are good. This line could also be written as
$data{$box}->{prior} = ...
}
# print @box_items;

# while (<BOX>) {
foreach ( @box_items ) {
($box,$group) = split;
$data{$box}{group} = $group; #??
Same comment as above
}

for my $table ( sort by_type( keys %data )) {
my @data = ($table, @{ $data{$table} } {qw/group prior/}); #??
This is called a hash slice. It is equivalent to
my @data = ($table, $data{$table}->{group}, $data{$table}->{prior} )

print "@data\n";
}

sub by_type {
$data{$a}{prior} <=> $data{$b}{prior}; #??
Same comment as first one
}
__DATA__
712480 3
712481 2
712482 1
712480 firstgreen
712481 firstblack
712482 firstblue

Hope that helps.

Boyd
.



Relevant Pages

  • Re: using variables as hashes
    ... RP> that $foo in the first loop above can become a hash on each iteration ... read perlreftut, perlref, perllol and perldsc. ...
    (comp.lang.perl.misc)
  • Re: multidimensional hash copy problem
    ... > I need to copy a multidimensional hash to work on the copy without modifying ... Hie thee quickly to perlreftut, ... This is perhaps a tad subtle if you're not clear on how references ... Thus, when you change data in that anonymous hash later, both ...
    (comp.lang.perl.misc)
  • Re: Net::SFTP ssh_args => [ ] syntax question...
    ... can put a hash inside the anonymous array following 'ssh_args', ... the code below defines the ssh port just as the docs recommend. ... reference to an anonymous array. ... perlreftut and perlref. ...
    (comp.lang.perl.misc)
  • Re: Passing hash to a subroutine
    ... hashes) into a function. ... You *have* figured out how to pass a hash into a function. ... What you haven't figured out is how to dereference it within ... perlreftut describes two different ways of dereferencing. ...
    (comp.lang.perl.misc)
  • Re: assigning list to hash entry
    ... There are some pages in the documentation about nested estructures, have a glance at perldsc for instance. ... Here you are making a copy of the the array and hash. ...
    (perl.beginners)