N
natedubya
I was writing a quick little program up, and I ran into a bit of
difficulty with it.
What I'm trying to end up with is a simple program that takes stdin and
takes any hexed numbers (like "%20", as in web addresses) and changes
them to their ascii counterpart. So, something like "hello%20world"
gets changed to "hello world". Easy enough.
What I have so far is simple:
s/%([0-9a-fA-F]{2})/chr(hex($1))/gee
Unfortunately, that dies. I was looking into using an extended
expression:
s/%([0-9a-fA-F]{2})/(??{ chr(hex($1)) })/gx
But that also doesn't work. I was just wondering, is there a way I can
do it this way? I managed to get around it by sticking the expression
inside a while loop and doing the replacement there, but I wanted to
know if this type of thing is even possible.
Thanks.
~Nate
difficulty with it.
What I'm trying to end up with is a simple program that takes stdin and
takes any hexed numbers (like "%20", as in web addresses) and changes
them to their ascii counterpart. So, something like "hello%20world"
gets changed to "hello world". Easy enough.
What I have so far is simple:
s/%([0-9a-fA-F]{2})/chr(hex($1))/gee
Unfortunately, that dies. I was looking into using an extended
expression:
s/%([0-9a-fA-F]{2})/(??{ chr(hex($1)) })/gx
But that also doesn't work. I was just wondering, is there a way I can
do it this way? I managed to get around it by sticking the expression
inside a while loop and doing the replacement there, but I wanted to
know if this type of thing is even possible.
Thanks.
~Nate