Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

The complicated problem

by zeezack (Initiate)
on Apr 01, 2008 at 12:05 UTC ( [id://677745]=perlquestion: print w/replies, xml ) Need Help??

zeezack has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
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...
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

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

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

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.

    --
    Andreas
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

      What's really sad about that site is that some of the translations are wrong. He treats PHP arrays like normal arrays--but they aren't: every array in PHP is an associative array. Then I saw this gem:

      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 :)

        Ah, you know what they say in Italian:
        Traduttore traditore

        Translator, 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

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> ...
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.

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)
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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://677745]
Approved by andreas1234567
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found