in reply to push an array into Hash of Array

Your update shows you need a HoAoA.
#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Indent = 1; my @array1 = qw{rose orange green}; my @array2 = qw{blue red}; my %hash; push @{$hash{q{first}}}, \@array1, \@array2; print Dumper \%hash;
$VAR1 = { 'first' => [ [ 'rose', 'orange', 'green' ], [ 'blue', 'red' ] ] };
update: clarified

Replies are listed 'Best First'.
Re^2: push an array into Hash of Array
by wrinkles (Pilgrim) on Sep 17, 2008 at 07:43 UTC
    Is q{first} == 'first' ? If so, I wonder why you would use the former in a line of code with so many curly braces. Just curious.
      Is q{first} == 'first'
      Yes, see perlop.

      Why use it? I find it easier to parse than ' and have adopted braces as delimiters and tend to stick to them. ymmv.

      In this case though $hash{first} works find (no need for either).

        But are you really 'storing' the arrays in that hash...or just the a reference to those arrays?

        If I undef array1 and array2..will I still have values in my hash?

        Or if I tie the Hash to a DB file. Will the file contain the contents of each of the arrays...or just the array references?