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

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

Replies are listed 'Best First'.
Re^13: Can't use string as an ARRAY ref
by Anonymous Monk on Aug 25, 2015 at 15:48 UTC
    Yes, and thats one my the problems. Like in this dump:
    $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' ], ];

    The code would fail, because in the first array $princ, it contains 3 arrays or:
    $VAR1 = [ [ '12345', 'MONICA', '01/01/1900', '0X10' ], [ '000001', 'MARY L', '01/01/2000', '0111P' ], [ '8884', 'JOHN M.', '01/01/1932', '0OK8' ], ];

    So, if any of the others don't match the size of $princ I would get this error:
    Can't use an undefined value as an ARRAY reference at...

    That is becuase of $person only having 2 arrays:
    $VAR1 = [ [ 'Q3.0', 'OK', '1900-01-01', 'N', 'O', 'O', 'X', 'Y' ], [ '12w', 'PL', '2000-01-02', 'N', 'P', 'O', 'X', 'A' ], ];

    I was thinking if there is a way to check the first array for its number of elements and make sure that all the others would match its size, that way the code would have the right data structure. What do you think?

      What do you think?

      I think you should register as a user and then I can msg you otherwise this thread will probably never end !

      poj

        I think you should register as a user and then I can msg you otherwise this thread will probably never end ! poj

        The threads that never end are the best kind, its like step by step by step with no omissions :D

      Going to post here, I hope it its OK to view it:
      $VAR1 = { '114112' => { 'princ' => [ [ '11121a', 'Joe Doe', '01/01/1900', '0' ], [ '11121a', 'Joe Doe', '01/01/1900', '0' ], [ '11121a', 'Joe Doe', '01/01/1900', '0' ], [ '2221', 'Mary Lou', '01/01/1900', '0' ], [ '2221', 'Mary Lou', '01/01/1900', '0' ], [ '1121', 'John Cr.', '01/01/1900', '0' ], [ '1121', 'John Cr.', '01/01/1900', '0' ], [ '4556', 'Marie Jua', '01/01/1900', '0' ], [ '4556', 'Marie Jua', '01/01/1900', '0' ], [ '2233', 'Junior Jr', '01/01/1900', '0' ], [ '2233', 'Junior Jr', '01/01/1900', '0' ], [ '2233', 'Junior Jr', '01/01/1900', '0' ], [ '8890', 'Carlos S', '01/01/1900', '0' ], [ '8890', 'Carlos S', '01/01/1900', '0' ], [ '1x223', 'Joana House', '01/01/1900', '0' ], [ '1x223', 'Joana House', '01/01/1900', '0' ], [ '1x223', 'Joana House', '01/01/1900', '0' ], [ '112w34', 'Carl Figure', '01/01/1900', '0' ], [ '112w34', 'Carl Figure', '01/01/1900', '0' ], [ '112w34', 'Carl Figure', '01/01/1900', '0' ], [ '223', 'Krumald Gerr', '01/01/1900', '0' ], [ '223', 'Krumald Gerr', '01/01/1900', '0' ], [ '2222', 'Karman Guia', '01/01/1900', '0' ], [ '2222', 'Karman Guia', '01/01/1900', '0' ] ], 'executed' => [ [ '22555', '01/01/1900', 'Barbara K', '4', 'Fatim Kar', '1900-01-01 00:00:00.000', '', 'E', '', '', '' ], [ '2233', '01/01/1900', 'Marua Lua', '3', 'Charles Br', '1900-01-01 00:00:00.000', '', 'E', '', '', '' ], [ '333', '01/01/1900', 'Bernado Cety', '2', 'Maria Iaer', '1900-01-01 00:00:00.000', '', 'E', '', '', '' ], [ '8890', '01/01/1900', 'Carlos S', '3', 'Torrado Demais', '1900-01-01 00:00:00.000', '', 'O', 'E', '', '' ] ], 'multi' => [ [ '3334e44', 'Hil Top', '05/05/2014', '3334e44' ], [ '3334t5', 'Carolis Des', '05/07/2012', '3334t5' ], [ '222111', 'Gualge Atro', '05/01/2014', '222111' ], [ '22211233', 'MOONEY THOMAS A', '05/24/2014', '22211233' ], [ 'A223', 'Marriana Guh', '05/14/2014', 'A223' ], [ '3334t5', 'Carolis Des', '05/07/2012', '3334t5' ], [ '1111w2', 'Casar Sala', '05/11/2013', '1111w2' ], [ '1111w2', 'Casar Sala', '05/11/2011', '1111w2' ], [ '11q222', 'HERNANDEZ KARINA M', '05/08/2014', '11q222' ], [ 'Q11222', 'SSimpatia Correga', '05/02/2014', 'Q11222' ], [ '222333', 'TIPOrino Car', '05/06/2014', '222333' ], [ '3334e44', 'Hil Top', '05/05/2014', '3334e44' ], [ '222e11', 'Gualge Atro', '01/01/2014', '222111' ], [ '22211233', 'MOONEY THOMAS A', '05/24/2014', '22211233' ], [ 'A223', 'Marriana Guh', '05/14/2014', 'A223' ], [ '11q222', 'HERNANDEZ KARINA M', '05/01/2014', '11q222' ], [ 'Q11222', 'SSimpatia Correga', '05/12/2014', 'Q11Z222' ], [ '222333', 'TIPOrino Car', '05/01/2011', '222333' ] ], 'type' => [ [ '1', '2002', 'CASA' ], [ '2', '2005', 'APT' ], [ '3', '2010', 'CAMA' ], [ '5', '2008', 'BEDBATH' ], [ '6', '2012', 'TIPO' ], [ '1', '2013', 'CONDO' ], [ '2', '2012', 'BUILD' ], [ '1', '2012', 'CONDO' ], [ '2', '1998', 'NEW' ], [ '1', '2001', 'SPLIT' ], [ '2', '2006', 'SELF' ], [ '3', '1997', 'SELF' ], [ '2', '2010', 'BUILD' ], [ '3', '2013', 'BUILD' ], [ '1', '2003', 'SELF' ], [ '2', '2007', 'SINGLE' ], [ '3', '1998', 'SELF' ], [ '1', '2011', 'SINGLE' ], [ '2', '2002', 'ONLY' ], [ '3', '2002', 'HOUSES' ], [ '2', '2004', 'SELF' ], [ '3', '2003', 'SELF' ], [ '1', '2005', 'CASA' ], [ '2', '2000', 'ONEH' ] ], 'person' => [ [ '2.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'P', 'P', '' ], [ '2.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', 'O', '' ], [ '2.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', 'O', '' ], [ '5.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', 'P', '' ], [ '5.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', 'O', '' ], [ '7.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', '', '' ], [ '5.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'P', 'O', 'P' ], [ '7.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'P', 'O', 'P', '' ], [ '7.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'P', 'O', '' ], [ '7.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', 'O', '' ], [ '7.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', 'O', '' ], [ '4.0', '', '1900-01-01 00:00:00.0 +00', 'N', '', 'O', 'O', 'P' ], [ '5.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', 'E', 'O' ], [ '2.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'P', 'O', '', '' ], [ '3.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'P', 'O', '', '' ], [ '3.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', '', '' ], [ '1.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'P', 'O', 'P', '' ], [ '7.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', 'O', '' ], [ '1.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'P', 'O', '', '' ], [ '1.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'P', '', '' ], [ '18.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'P', '', '' ], [ '7.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'P', '', '', '' ], [ '10.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'P', '', '' ], [ '14.0', '', '1900-01-01 00:00:00.0 +00', 'N', 'O', 'O', 'P', '' ] ] } };

      Thanks!