On 3/2/06, maillists <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to filter quotes out of a web form and replace them with
> &quot;
>
>     $Values->{text_field} =~ s/"/&quot;/;
>     return;
>
> However, This does not seem to work. Is this right?
> Also, I would like to replace the single quote '
>
> Thanks
> Rick

What do you mean by "does not seem to work"?  The see the following
test code and output.

code
#!/usr/bin/perl

my $var = qq(this has "foo" style quotes);
print "$var\n";
$var =~ s/"/&quot;/g;
print "$var\n";


output
this has "foo" style quotes
this has &quot;foo&quot; style quotes

As for replacing single quotes, if you wish both to be &quot; (a
gramatical error in nested quotes) then you can use

$var =~ s/["']/&quot;/g;

Otherwise you will need a second substitution

$var =~ s/"/&quot;/g;
$var =~ s/'/&apos;/g;

--
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