Try this, and remember - with XML there are more than one you have to
change:

sub xc {
#returns text free of XML baddies - xc = xml clean
        my $data = $_[0];
        $data =~ s/&/&/g;
        $data =~ s/</&lt;/g;
        $data =~ s/>/&gt;/g;
        $data =~ s/'/&apos;/g;
        $data =~ s/"/&quot;/g;
        return $data;
} 

-----Original Message-----
From: John [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 03, 2005 9:36 AM
To: Perl Beginners
Subject: replacing special chars

Hello to all

I want to replace the & with the &amp;

I use the command s/\&/\&amp;/; with no luck

Does anybody know what am i missing here?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to