perl form parsing! HELP!

He has: 1,758 posts

Joined: Jul 2002

Hey guys,

I'm really stuck on this one and i'm sure there must be an easier way, but i'm not completly sure what it is.

Basically, i have a client that wants to be able to edit the html on their webpage, via the web and without using ftp, so i've written a REALLY basic bit of perl that will open a text file print it inside a text box, then save it back out when its submitted.

The problem is, is that all the non alpha numeric characters are converted to %whatever (ie ! is %21).

In the past i've just used a simple regex to replace the code with the proper character and be done with it, but i did a solution that will do them all, without me having to do it all by hand (cos there must be 1000's of characters, and processing that many would be a nightmare wouldnt it?)

$content =~ s/%21/\!/g;'

Any ideas?

you can see the script running at http://www.magicshop.co.uk/admin/index.pl hit the submit button and you'll see what i mean!

any help would be appreciated.

Thanks!

Andy

He has: 1,758 posts

Joined: Jul 2002

heh... forget it... found the solution eventually!

$pagebody_content =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge;'

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.