foreach my $line (@data) { my ($linecount, $filename) = split(/\s+/, $line); $filename =~ s/^$in_prefix//; # strip base directory from filename my ($campaign, $month, $fname) = split('/', $filename); # info is stored in the directory nesting push @files, { campaign => $campaign, month => $month, file => $fname, count => $count, sort => "$campaign:$month:$file" }; }