in reply to Re^3: Sorting files by 3 numbers in the name
in thread Sorting files by 3 numbers in the name

agreed, with split it's a plus! =)

I wonder about the best idiomatic way ( with or w/o List::Util ) to shorten the or chain such that we don't need to repeat the field names.

use strict; use warnings; use Data::Dump; use List::Util qw/first/; $\="\n"; # --- init my @fields = qw( RUN DISTRICT COPY TOTAL ); my %a = map { $_ => 1- int rand 3 } @fields; my %b = map { $_ => 1- int rand 3 } @fields; dd \@fields,\%a,\%b; # --- w/o List::Util my $last; my $field; for (@fields) { $field =$_; $last = $a{$_} <=> $b{$_} and last; } print "$field,$last"; # --- with List::Util print first { $last = $a{$_} <=> $b{$_} } @fields; print $last;

( ["RUN", "DISTRICT", "COPY", "TOTAL"], { COPY => -1, DISTRICT => 1, RUN => 1, TOTAL => -1 }, { COPY => -1, DISTRICT => 1, RUN => 1, TOTAL => 0 }, ) TOTAL,-1 TOTAL -1

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!