in reply to Re: Adding an element to an array
in thread Adding an element to an array

Hi!
I am trying to use your code but I am getting this error:
Error: Global symbol "%row" requires explicit package name at... My data structure is like this:
[ [ "John Doe", "Main Street", "House 1", ], [ "John Doe", "Main Street", "House 1", ], ... ]

Trying to apply your code in here:
my %homes_by_names; foreach my $row ( @data ) { $row{'HOME_COUNT'} = $homes_by_name{ $row{ HOME } }; }

Thanks for looking!

Replies are listed 'Best First'.
Re^3: Adding an element to an array
by NetWallah (Canon) on Oct 15, 2015 at 15:40 UTC
    $row is a hashref. Try:
    $row->{'HOME_COUNT'} = $homes_by_name{ $row->{ HOME } };

            Software efficiency halves every 18 months, thus compensating for Moore's Law.

      I'm getting this:
      Not a HASH reference at ...

        How are you creating @data ?
        poj