Advertisement
cd62131

Print Max Values

Jan 30th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.39 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use List::Util 'max';
  5. use utf8;
  6. use open qw(:encoding(utf8) :std);
  7. use feature 'say';
  8. open my $in, "dat" or die;
  9. my %h = ();
  10. while (<$in>) {
  11.   chomp;
  12.   my @b = split;
  13.   next if (!@b or $b[0] =~ /\AItem\z/);
  14.   $h{$b[0]} = ($b[1] + 0) * ($b[2] + 0);
  15. }
  16. my $max = max(values %h);
  17. say join ' ', map { $h{$_} == $max ? ($_, $max) : () } keys %h;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement