Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; ... my @all_profile; my %homes_by_names; foreach my $row ( @{ $sql } ) { my %profile; $profile{ NAME } = $row->{'name'}; $profile{ ADDRESS } = $row->{'address'}; $profile{ HOME } = $row->{'home'}; # I will need to count the how many homes here push ( @{ $homes_by_names{$profile{ HOME } } }, \%profile); push @all_profile, { 'HOME COUNT' => scalar @{ $homes_by_names{HO +ME} }; push @all_profile, \%profile; } print Dumper \@all_profile; $VAR1 = [ { 'NAME' => 'John Doe', 'ADDRESS' => 'Main Street', 'HOME' => 'House 1', 'HOME COUNT' => '3', }, ... =data # Sample data to show how I need to count how many Houses per person John Doe, Main Street, House 1 John Doe, Main Street, House 1 John Doe, Main Street, House 1 Mary Lou, Central Street, House 1 Mary Lou, Central Street, House 1 Mary Lou, Central Street, House 1 Mary Lou, Central Street, House 1 Jane B,. Squere Rd., House 1 Maria D., Pat street, House B Maria D., Pat street, House B
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Adding an element to an array
by AppleFritter (Vicar) on Oct 14, 2015 at 18:51 UTC | |
by Anonymous Monk on Oct 14, 2015 at 19:24 UTC | |
by Pope-O-Matik (Pilgrim) on Oct 14, 2015 at 23:56 UTC | |
|
Re: Adding an element to an array
by poj (Abbot) on Oct 14, 2015 at 19:30 UTC | |
by Anonymous Monk on Oct 15, 2015 at 15:30 UTC | |
by NetWallah (Canon) on Oct 15, 2015 at 15:40 UTC | |
by Anonymous Monk on Oct 15, 2015 at 15:54 UTC | |
by poj (Abbot) on Oct 15, 2015 at 16:12 UTC | |
| |
by Anonymous Monk on Oct 14, 2015 at 19:43 UTC | |
by davido (Cardinal) on Oct 15, 2015 at 06:59 UTC | |
by poj (Abbot) on Oct 14, 2015 at 20:10 UTC | |
by Anonymous Monk on Oct 15, 2015 at 13:57 UTC | |
by sandeepb (Novice) on Oct 16, 2015 at 10:51 UTC |