PHP code to Perl plx


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PHP code to Perl plx
# 1  
Old 08-10-2013
PHP code to Perl plx

hi everybody
this ex-PHP code:
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:
Code:
$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
tip78
# 2  
Old 08-10-2013
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?

Quote:
Originally Posted by tip78
...
Code:
...
for (my $g = 0; $g < length($l); $g++){
   $str.= chr(ord($l[$g]) ^ ord($h[$g % length($h)]));
}
...

...
And what are sample values of $l and $h?
# 3  
Old 08-10-2013
it is written in the second row:
Quote:
this ex-PHP code:
$h is just a bunch of letters and digits
and $l is look like this (the part of it):
Quote:
@-+]"▒/▒oXaq4}{KT">gpVg{XCJmzm1fkNtt{`(X
Uc[~aTnqz:75W 1;xAG
1@}Y▒&N
ESQP)]DTD▒\,Gz{_ML^^Dv
\9V pQ4KFGOQPFs|C FPWZC^_jQsQ1knTuuj
KNZ":F\
~j[[ $>OacCrj,Cd<▒4!'Dsp{OZ9CJmzEftqbhp_QiWb m
N'!UdFDL!Md_S'GK_Pd

._-\I#jhu
uRFqsCw"F&U
:QC^_ksQ
WU*TGklTp- EG %:^
Xr!~jLU)VsCoYtBG+\ThahgDrsp{
R|*\;L^^Kg!P\FZRPFv!z}o@#@W|RAlcY@$@OUQQZ]5@@
GFQP@<LS(H▒sU4k#U#]\Ma]'K
nOhQ;8V ~jVsC(G#Y4@*KKTsh1gVd/ LJT]l@|uw\c,>(YJ
tLBuy3 <2K3Kx><D%
Y

rd%P|Y%}SW@J.P K`[TZYS\1RBgGB*Q@uGQpLRFQP@9LT^G|hdT-V
\tMdmK
OmibPqij
@/dCxO`pcB;Y

(smGbVg~(LJT>,!6j W6,wJ
L~v"8fz|v
gm,B8V:?
,YW@CaRSFRM]SW1K]LTJ&JH[I_
X9VTIgPP\7P \X▒FyC!FU'
J[V|hdP(V
1T<Cg
@(uK@/(>0BcBj*CxzBpw7dlX[▒
<4Gq|qt\c+:[\k▒8%.87!- d
ph
x0G
JG▒"YW@CaRSFEC▒N
and source ($answer) is like that:
Quote:
{"data":"hX8L^^\u0002@[ZUN\\}\u0003\u0003\u001e\u0013\u0014GB,QG\t_B\u0014PQ\u0016\u0004t\u0006\u001dTvFQP\u0006A\u0016\u00 1d\u0003\u0002G_khs\u0005 ........ etc ............ }
tip78
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Test Server - Forum Code Changes for PHP 5.3.10 to PHP 7

Here is some docs of my ongoing work to port this forum PHP code which is running on 5.3.10, to PHP 7. Motivation: Unfortunately, every thing that has a beginning must have an end. PHP 5.6 active support ended January 19, 2017. It will receive security support until December 31, 2018. #1 ... (7 Replies)
Discussion started by: Neo
7 Replies

2. Shell Programming and Scripting

PHP - add rm %dir to php code

Hello everyone, I'm trying to modify a php file to perform 2 actions in an if statement. // If the delete button is pressed if(isset($_GET) && isset($_GET)) { if(!mysql_query("DELETE FROM users WHERE User='".$_GET."'",$link)) ... (2 Replies)
Discussion started by: da1
2 Replies

3. Shell Programming and Scripting

perl code

What is the meaning of below code, which is capturing from one file . $runDate = $1 if $str =~ m/,"TransactTime":"({10})/; # get transaction date as run date Is it the date from the first line of file or last line of file??? (Note:Each line from the file contains date) (2 Replies)
Discussion started by: aish11
2 Replies

4. Shell Programming and Scripting

php to perl help

Hey guys, I have some php code that I am trying to convert to perl code and I am having some probelms. I am posting my php to show what I am having difficulty converting. I know all the $_GET's will not work but I have taken care of that in my code. My main issue is with the bind_results, is... (2 Replies)
Discussion started by: Joey12
2 Replies

5. Programming

Perl- How to catch the file in perl code?

Hi, plz see the below code , i have catch the file "Orders.20110714.out "file as a Orders*.out. but it giving me an error .it does not open the file. if the same thing i have done by code code-> ls Orders*.out then it gives me the output Orders.20110714.out i am trying apply the... (1 Reply)
Discussion started by: pspriyanka
1 Replies

6. Shell Programming and Scripting

perl: a way to see a sub code in debug mode: perl -de 0 ?

Is there a way to see or print a sub code? Sometime a sub could be already defined, but in the debug mode (so, interactively) it could be already out of screen. So, I would think about a way to check if the sub is defined (just 'defined' is not a problem) and how it is defined. Also, if... (4 Replies)
Discussion started by: alex_5161
4 Replies

7. Web Development

I can't open my index.php page after insert php code

Hello guys, Does anyone can help me? I've just made my simple index.php without any code, but after insert session code to check if any user is authenticated, my index.php doesn't work anymore. Any fresh eyes could help me to see what and where the code is wrong? <? if... (6 Replies)
Discussion started by: metalfreakbr
6 Replies

8. Web Development

php and perl on apache server

I'm having problems opening php and perl files on Apache. The server hasn't any association with those type of files by default and a window asking to choose a program to open them popups from the browser. How can I do to process them with the browser Thanks in advance. (1 Reply)
Discussion started by: capibolso
1 Replies

9. Shell Programming and Scripting

Calling an Executable C file from the script (URGENT HELP PLX ! )

hi i'm trying to use tcl/tk on unix machine to call an executable C file .. i am trying just a simple button like this one button .list -text "LIST" -command filename pack .list -padx 10 -pady 10 but its giving me error message when i save it in a file eg script.tcl the button is... (7 Replies)
Discussion started by: phantom308
7 Replies
Login or Register to Ask a Question