Sami_R has asked for the wisdom of the Perl Monks concerning the following question:
Hi PerlMonks,
I have a list of array hash
my @array_data;
for example: when I loop through I get
foreach my $hash (@array_data) { $logger->log( "HASH NOW: =====> ". Dumper($hash)); }
I get…
HASH NOW: =====> $VAR1 = { 'Name' => 'First Segment', 'Balance' => '183.57', 'days' => 0, 'First Date' => '12/02/2020', 'payment' => 0, 'Activity Date' => '07/05/2020', 'Total Commission' => 0, }; HASH NOW: =====> $VAR1 = { 'Name' => 'Discontinue Segment', 'Balance' => '67.14', 'days' => 3, 'First Date' => '17/02/2020', 'payment' => 0, 'Activity Date' => '27/03/2020', 'Total Commission' => 0.12, }; HASH NOW: =====> $VAR1 = { 'Name' => 'Last Segment', 'Balance' => '12.56', 'days' => 7, 'First Date' => '19/03/2020', 'payment' => 0, 'Activity Date' => '21/04/2020', 'Total Commission' => 0, };
and so on ...
Expected output:
my $activity_date = $hash->{'Activity Date'}; print “Activity date: $activity_date”;
output: Activity date: 07/05/2020
Have taken previous examples from PerlMonks tried this:
my $max_date = 0; $_ > $max_date and $max_date = $_ for values @array_data;
Terribly I am doing wrong by not using the key (I couldn't able to get the desired output, sorry don't know), please give me directions to get the maximum date from the array list. Thank you,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Find maximum (Activity) date from array hash.
by hippo (Bishop) on Jun 02, 2020 at 20:27 UTC | |
by Sami_R (Sexton) on Jun 02, 2020 at 23:36 UTC | |
Re: Find maximum (Activity) date from array hash.
by CountZero (Bishop) on Jun 02, 2020 at 20:08 UTC | |
by Sami_R (Sexton) on Jun 02, 2020 at 23:41 UTC |
Back to
Seekers of Perl Wisdom