in reply to Re: Loading of Complex Data Structures
in thread Loading of Complex Data Structures

The $array_ref is the record set. One line of the record set looks like the following:
...
334 Capped 28 5034366 16777215 NULL NULL NULL
373 Capped 28 5034366 16777215 NULL NULL NULL
...
$hash_ref is an empty hash.

It should look like:
Key value = '55034366';
$VAR148 = [ [ '334', 'Capped ', 28, 16777215, undef, undef ], [ '373 ', 'Capped ', 28, 16777215, undef, undef ], ]
  • Comment on Re^2: Loading of Complex Data Structures

Replies are listed 'Best First'.
Re^3: Loading of Complex Data Structures
by Anonymous Monk on Aug 25, 2004 at 21:23 UTC
    The following code will do what you want:
    #!/usr/bin/perl use Data::Dumper; my %HoA = (); my %hash_track = (); while(<DATA>) { chomp($_); my (@stuff) = split(" ", $_); &fill(@stuff); } print Dumper(\%HoA); sub fill() { my @a = @_; my @ar = @a[0,1,2,4,5,6,7]; my $h = $a[3]; $HoA{$h}[$hash_track{$h}] = [ @ar ]; $hash_track{$h}++; } __DATA__ 334 Capped 28 5034366 16777215 NULL NULL NULL 373 Capped 28 5034366 16777215 NULL NULL NULL
    output:
    $VAR1 = { '5034366' => [ [ '334', 'Capped', '28', '16777215', 'NULL', 'NULL', 'NULL' ], [ '373', 'Capped', '28', '16777215', 'NULL', 'NULL', 'NULL' ] ] };

    %hash_track is used to increment the first level %HoA array.

    hope this helps,

    davidj

      the above is mine. For some reason I entered it as Anonymous. Silly me

      davidj