PHP code to Perl plx

hi everybody
this ex-PHP code:

use JSON;
use URI::Escape;

my $obj = decode_json($answer);
my $l = $obj->{data};
my $h = substr($useragent, 0, 25) . $fuid01 . 'I keep watch over you ;)';
my $str = "";
for (my $g = 0; $g < length($l); $g++){
   $str.= chr(ord($l[$g]) ^ ord($h[$g % length($h)]));
}
print uri_unescape($str);

is not working on Perl
because
$l[$g] - is an array in perl but it's not array in PHP
this one line is not working because of that:

$str.= chr(ord($l[$g]) ^ ord($h[$g % length($h)]));

how to do it right?

---------- Post updated 08-10-13 at 11:24 ---------- Previous update was 08-09-13 at 20:11 ----------

still stucked

I don't quite understand.
Your code looks eerily similar to Perl code, but is obviously incorrect. So I guess it's PHP code (?)

If that's the case, then what does this "for" loop do in PHP?

And what are sample values of $l and $h?

it is written in the second row:

$h is just a bunch of letters and digits
and $l is look like this (the part of it):

and source ($answer) is like that: