for my $temp (@line) { $_ = lc($temp); s/$_/$words{$_} ? "$temp " : "[$temp] "/ex; print; }