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

Reply via email to