in reply to How can I use the value of a scalar as the name of an array variable?

Learn about a Hash of Arrays:
my %HoA; while (<>) { chomp; my( $category, $item ) = split /\t/, $_, 2; push @{$HoA{$category}}, $item; } for my category ( sort keys %HoA ) { local $" = ", "; print "$category: @{$HoA{$category}}\n"; }
  • Comment on Re: Can I determine if the value of a variable is the same as an arrays name?
  • Download Code

Replies are listed 'Best First'.
Re: Answer: Can I determine if the value of a variable is the same as an arrays name?
by extremely (Priest) on Nov 29, 2000 at 11:24 UTC
    For the text file example in the "Q", that split should be my ($cat, $item) = split ' ', $_; so that the magic split on space will be in force, why the original "Q"er was doing it that way, I have no idea.

    --
    $you = new YOU;
    honk() if $you->love(perl)