Thanks everyone for your help.

I actually figured it out myself -

spaces get sent as "+" in a CGI form
commas get sent in their hex equivalent in a CGI form

so... i needed to convert my commas from their hex to their ascii equiv
first, and then do a character replace on both the plus and comma symbols
using a simple tr///;

So... i do my hex to ascii translation first, and the character replace
second.

so simple.

AARRRGH! :)


----- Original Message -----
From: "Scot Robnett" <[EMAIL PROTECTED]>
To: "steve ryan" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, June 09, 2003 12:07 AM
Subject: RE: Simple character replace problem


> Talk about a confusing-looking hack, but this one seemed to work to take
> care of the hex values.
>
> $value =~ s/(\%){1}(\d|[a-fA-F]){1}(\d|[a-fA-F]){1}/ /g;
>
>
> Scot R.
> inSite
>
>
> -----Original Message-----
> From: steve ryan [mailto:[EMAIL PROTECTED]
> Sent: Sunday, June 08, 2003 5:38 PM
> To: [EMAIL PROTECTED]
> Subject: Simple character replace problem
>
>
> Hi,
>
> I was wondering if someone could help me with this as it is driving me
> insane!
>
> I have a CGI script which writes a series of form fields to a
tab-delimited
> file.
>
> I read in the fields and then replace certain characters (like commas
etc.)
>
> The problem is -
>
> 1. My "+" symbols are not being replaced (i.e. the spaces in the form)
> 2. My HEX/Ascii conversion isn't working (i.e. i am getting things like
%2C)
>
> Here is my conversion code -
>
> # replace new lines with a space
>                         $value =~ s/\n/ /g;
> # remove hard returns
>                         $value =~ s/\r//g;
> # remove ^M's
>                         $value =~ s/\cM//g;
> # replace commas with a space
>                         $value =~ s/,/ /g;
> # replace + with a space
>                         $value =~ tr/+/ /;
> # or sometimes $value =~ s/\+/ /g;
>
> # replace hex pairs back to it's acsii equivalent
>                         $value =~
> s/%([\da-fA-F][\da-fA-F])/pack("C",hex($1))/eg;
>
> Any idea why this isn't working?
>
> Thanks,
> Steve
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to