View Single Post
  #1 (permalink)  
Old 01-15-04, 01:34 AM
phptalk phptalk is offline
New Member
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Post convert perl code to php

Hi

I need to convert below perl scripts to php scripts. I dont know much on perl and wonder if anyone there can assist me to convert below perl script to php scripts. thanks in advance.

regards
James

sub encrpt {

my ($key, $text) = @_;
my ($encrypt, $key, @text, @toc(;

@key = @{$key};
@text = split //, $text;

foreach $line (@key) {
my @line = split //, $line;
push @toc, [ @line ];
}

foreach $char (@text {
my ( $linevar, $linechar, $linenum, $ord);

$linevar = rand 95; $linevar =!~ s /\..+//;
$linechar = $toc[0] -> [$linevar];
redo if $linechar eg '';

$linenum = 0;
for $x (2 ..4)
{
if (($linevar / $x) !~ /\./)
{
$linenum = $x; last;
}
}

$linenum = 1;
if $linenum == 0;
redo if $toc[$linenum];

$ord = ord($char);
$ord -= 32;
$enc = $toc[$linenum]->[$ord];
redo if $enc eq '';
$encrypt .= $linechar . $enc;

}

echo $encrypt;

}
Reply With Quote