Current location: Hot Scripts Forums » Programming Languages » Perl » convert perl code to php


convert perl code to php

Reply
  #1 (permalink)  
Old 01-15-04, 02: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;

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-15-04, 03:06 AM
phptalk phptalk is offline
New Member
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question sorry for the typing mistake earlier post.

here is the right code:

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;

}

return $encrypt;

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP code to edit a text file mdhall Script Requests 12 12-23-10 05:03 AM
protecting code in PHP ckb PHP 12 01-02-04 09:53 AM
How to convert php generated pages to SE friendly HTML or PHP(SE friendly) -CLASS 101 crippled PHP 1 11-16-03 07:37 AM
php visual basic perl cgi - outsource programming to india outsource_india General Advertisements 0 10-28-03 04:21 AM
Perl code : print "." x 20; - How to do it with PHP ? kevin PHP 2 07-04-03 05:29 AM


All times are GMT -5. The time now is 12:24 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.