foreach my $in ($message, $name, $mail) { $in = $q->escapeHTML($in); # and of course you can do your subs here to: $in =~ s/\(b\)//ig; # ... }