in reply to Re^8: Can't use string as an ARRAY ref
in thread Can't use string as an ARRAY ref

Here is a sample, are these the structures you asked?
$VAR1 = { 'first' => { 'princ' =>[ [ '12345', 'MONICA', '01/01/1900', '0X10' ], [ '000001', 'MARY L', '01/01/2000', '0111P' ], [ '8884', 'JOHN M.', '01/01/1932', '0OK8' ], ], 'type' =>[ [ 'Main', '1900', 'Red', ], [ 'APT', '1290', 'Blue', ], [ 'AVAL', '1921', 'Green', ], ], 'person' => [ [ 'Q3.0', 'OK', '1900-01-01', 'N', 'O', 'O', 'X', 'Y' ], [ '12w', 'PL', '2000-01-02', 'N', 'P', 'O', 'X', 'A' ], ] }, 'second' => { 'princ' =>[ [ '12345', 'MONICA', '01/01/1900', '0X10' ], [ '000001', 'MARY L', '01/01/2000', '0111P' ], [ '8884', 'JOHN M.', '01/01/1932', '0OK8' ], ], 'type' =>[ [ 'Main', '1900', 'Red', ], [ 'APT', '1290', 'Blue', ], [ 'AVAL', '1921', 'Green', ], ], 'person' => [ [ 'Q3.0', 'OK', '1900-01-01', 'N', 'O', 'O', 'X', 'Y' ], [ '12w', 'PL', '2000-01-02', 'N', 'P', 'O', 'X', 'A' ], ] } };

Thanks!

Replies are listed 'Best First'.
Re^10: Can't use string as an ARRAY ref
by poj (Abbot) on Aug 24, 2015 at 18:46 UTC

    No, that looks like a dump of $just_data. I wanted a dump of these ($princ, $type, $person) = get_person(); that are used to build $just_data.

    poj
      Hi, these are the dump of ($princ, $type, $person) = get_person();
      $VAR1 = [ [ '12345', 'MONICA', '01/01/1900', '0X10' ], [ '000001', 'MARY L', '01/01/2000', '0111P' ], [ '8884', 'JOHN M.', '01/01/1932', '0OK8' ], ]; $VAR1 = [ [ 'Main', '1900', 'Red', ], [ 'APT', '1290', 'Blue', ], [ 'AVAL', '1921', 'Green', ], ]; $VAR1 = [ [ 'Q3.0', 'OK', '1900-01-01', 'N', 'O', 'O', 'X', 'Y' ], [ '12w', 'PL', '2000-01-02', 'N', 'P', 'O', 'X', 'A' ], ];

        In that case don't understand how this code works as I would expect the first column in each array to be a member number.

        foreach my $princ_row ( @{$princ} ) { my $member_number = shift @{ $princ_row }; push ( @{ $just_data->{$member_number}{princ} }, $princ_row); } foreach my $type_row ( @{$type} ) { my $member_number = shift @{ $type_row }; push ( @{ $just_data->{$member_number}{type} }, $type_row); } foreach my $person_row ( @{$person} ) { my $member_number = shift @{ $person_row }; push ( @{ $just_data->{$member_number}{person} }, $person_row); }

        It looks from the code that you are trying print a record from each array in a block of three tables where the lower 2 tables (type,person) are along side each other, is that correct ? The only way this will work is if each table contain only one record, is that correct ?


        poj