#!/usr/bin/perl -w #use strict; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI ':standard'; my $one = "apple"; my $two = "pear"; my $three = "ba\$\£na\¨na"; my @vars; my $ILLEGAL_CHARS = qr/[^\w\.-\s\@\(\)\Ó,]/; @vars = ($one,$two,$three); ($one,$two,$three) = legal(@vars); print header(), start_html(-title => "fruits"); print "$one,$two,$three"; print end_html(); sub legal { foreach $item (@vars) { $item =~ s/$ILLEGAL_CHARS/_/g; } return @vars; }