my @files = map {&makefiles} @in; sub makefiles { my ($count, $file) = split; $file =~ s/^$in_prefix//; my ($campaign, $month, $fname) = split /\//, $file; return { # not strictly necessary, but *readable* campaign => $campaign, month => $month, file => $fname, count => $count, sort => "$campaign:$month:$file" }; }