sub make_singular { my $word = shift; $word =~ s/s$//; my @in_sub_filesize_names = @filesize_names; # added this line, the output is still wrong. my @short_sizes = map(s/^(\w)\w{1,}$/$1b/,@in_sub_filesize_names); if (grep(/\L$word\E/,@short_sizes)) { $word = $filesize_names[firstidx { $_ eq lc $word} @short_sizes]; } return lc $word; }