Practice: kiosk log

Parse city and shillings.

Parse city and shillings.

Goal

Say 25 units, 1000 shillings, and Nairobi as busiest.

use strict;
use warnings;
use feature 'say';

my @rows = (
  { city => "Nairobi", units => 12, shillings => 480 },
  { city => "Mombasa", units => 8, shillings => 320 },
  { city => "Kisumu", units => 5, shillings => 200 },
);
my ($units, $shillings, $busiest) = (0, 0, $rows[0]);
foreach my $r (@rows) {
  $units += $r->{units};
  $shillings += $r->{shillings};
  $busiest = $r if $r->{units} > $busiest->{units};
}
say "units $units";
say "shillings $shillings";
say "busiest $busiest->{city}";