On 07/09/2011 01:15, Rajeev Prasad wrote:

which of the two is better? thx.

$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

or
$value =~ s/%(..)/chr(hex($1))/ge;

in both cases if the input string has \ in it, it is being converted to \\


i read...
chr =  function is used to convert ASCII or Unicode values into their 
equivalent characters...
pack = here to convert hex to character ("C")...

I would prefer a combination of the two:

  s/%([a-fA-F0-9]{2})/chr hex $1/eg;

or perhaps

  s/%([[:xdigit:]]{2})/chr hex $1/eg;

Alternatively, the URI::Escape module provides uri_unescape(), which
will do this for you (in a way almost identical to the first of these
two options).

HTH,

Rob




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to