Re: The complicated problem
by grep (Monsignor) on Apr 01, 2008 at 12:40 UTC
|
Hahaha.... It's an april fools joke.
I am to translate this PERL script into PHP.
and
if ( $debug ) {
use warnings();
use diagnostics();
use CGI();
}
grep
One dead unjugged rabbit fish later...
| [reply] [d/l] |
Re: The complicated problem
by Old_Gray_Bear (Bishop) on Apr 01, 2008 at 17:29 UTC
|
Simple -- It's a Three Step Process:
First: change the first line of your code from #!/usr/bin/perl to #!/usr/bin/php
Second: correct all the errors.
Third: ....
----
I Go Back to Sleep, Now.
OGB
| [reply] [d/l] [select] |
Re: The complicated problem
by grizzley (Chaplain) on Apr 01, 2008 at 12:17 UTC
|
Answer 1: Install mod_perl - don't translate :)
Answer 2: If you really, really want to: translate line-by-line and come back when you encounter any problem in particular lines
| [reply] |
Re: The complicated problem
by talexb (Chancellor) on Apr 01, 2008 at 15:27 UTC
|
There are many things wrong with your post.
First of all, this is a Perl web site. Asking for help translating a piece of code *away* from Perl isn't going to get you many takers.
Secondly, this web site is a repository of Perl knowledge, thus a *useful* title is very important. A node title of 'The complicated problem' doesn't mean anything to anyone.
Thirdly, do you imagine that posting over *a thousand* lines of Perl would be useful to anyone? Do you expect someone's going to translate *the whole thing* to PHP for you? That sounds like a consulting engagement to me.
Fourthly, does your employer (or, presumably, the owner of this intellectual property) know that you've posted a big chunk of their code on a public forum?
Fifth, why would you join a site and then immediately ask such a thing? Why not join, hang out for a while, and then start asking questions? You've done the equivalent of bursting into a room and blurting out a question.
Read the site documentation and get a clue, please.
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds
| [reply] |
Re: The complicated problem
by andreas1234567 (Vicar) on Apr 01, 2008 at 12:45 UTC
|
A recent and related discussion is How to retain perl in-house code. I suggest you read it.
Your code looks like a total mess. You don't mention your reasons for migrating, but you must fully understand what it does and what it should do (not always the same)
in order to be able to transform it. Pick up a copy of a Perl book, and start reading up on topics like Best Practices.
Ten Essential Development Practices (perl.com, by Damian Conway,
July 14, 2005) might be a good start.
| [reply] |
Re: The complicated problem
by CountZero (Bishop) on Apr 01, 2008 at 20:32 UTC
|
Strange as it may be, there is a web-page on translating Perl into PHP: Perl to PHP Translation.
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] |
|
Perl:
$a = keys(%h);
$b = values(%h);
PHP:
$a = array_keys($h);
$b = array_values($h);
The Perl will give you the counts, the PHP returns the actual values...
And that's just the beginning of what this guy says you should do... I'm pretty sure that he doesn't know Perl, but at least it gave me something laugh about :) | [reply] [d/l] |
|
Ah, you know what they say in Italian:Traduttore traditoreTranslator, traitor
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] |
|
|
Re: The complicated problem
by apl (Monsignor) on Apr 01, 2008 at 12:59 UTC
|
April Fools joke or not, you might have used <readmore> ... | [reply] |
Re: The complicated problem
by Herkum (Parson) on Apr 01, 2008 at 14:34 UTC
|
If this was an april fools joke, it was one I could have lived without.
| [reply] |
Re: The complicated problem
by ikegami (Patriarch) on Apr 01, 2008 at 18:58 UTC
|
I like how you called it "PERL", cause it definitely doesn't look like "Perl" to me. (The problems include 11 levels of indents, continual repetition of expressions like "$dbs{$db}->{tbls}->{$table}->{indx}", and a complete lack of variable localization)
| [reply] [d/l] |
Re: The complicated problem
by GrandFather (Saint) on Apr 01, 2008 at 23:13 UTC
|
The code is so bad it must have been translated to Perl from PHP in the first place so just find the original PHP and the job is done.
Perl is environmentally friendly - it saves trees
| [reply] |