in reply to Fun with arrays

Hashes sound like the way forward
open(my $cities_fh => 'cities.txt') or die "ack: $!"; my %cities; chomp, $cities{lc substr $_, 0, 3} = $_ while <$cities_fh>; open(my $devices_fh => 'devices.txt') or die "ack: $!"; /^dev-([a-z]+)/ and print "$cities{$1} $_" while <$devices_fh>;
So create a hash with the keys as the first three letters of the city, lower-cased, and the values as the city & state name. Then iterate through the devices file grabbing the city identifier then printing out the city & state name along with the filename.
HTH

_________
broquaint