Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Has anyone attempted to create a PHP to Perl converter?

by taint (Chaplain)
on Nov 13, 2013 at 07:11 UTC ( [id://1062344]=note: print w/replies, xml ) Need Help??


in reply to Re: Has anyone attempted to create a PHP to Perl converter?
in thread Has anyone attempted to create a PHP to Perl converter?

Thanks for your reply.

I think given my current (Perl) skillset. It would indeed require the "human interaction" you describe. Much of it seems to be alot of (s)print(f) sort of stuff. And much of the syntax even closely mimics Perl. So it really doesn't seem to me, a, "quantum leap", or anything. But, as I stated above; it'll probably take some accomplished Perl RE skills.

Thanks again, for taking the time to respond.

--Chris

#!/usr/bin/perl -Tw
use Perl::Always or die;
my $perl_version = (5.12.5);
print $perl_version;
  • Comment on Re^2: Has anyone attempted to create a PHP to Perl converter?

Replies are listed 'Best First'.
Re^3: Has anyone attempted to create a PHP to Perl converter?
by davido (Cardinal) on Nov 13, 2013 at 07:55 UTC

    It's a little more than a regexp problem. You can't exactly substitute a PHP array with a Perl array, or even a Perl hash, because the PHP array is actually an ordered map. An ordered map has different performance and semantic characteristics from a Perl array or a Perl hash. And that's just where the differences begin.

    A human can look and say, "That algorithm that uses a PHP array can be expressed with a Perl array." Or "This other algorithm needs a Perl hash." Or "This algorithm is going to require a hash, and an array crossreference to maintain order." A dumb tool would be forced to make compromises in every case; it would have to maintain the hash, and an ordered list to emulate an ordered map. This is not to say that an ordered map is more powerful, but that it's a different container. In specific cases, Perl could mimic enough of its behavior using an array, and in others, enough of its behavior using a hash. But in a general case, both would have to be used together. Programming for the general case, then, would be inefficient for many specific uses. A human can make the distinction, or even rewrite the algorithm to play to Perl's strengths instead of PHP's strengths.

    Once that problem is solved, there will be many more paradigm mismatches, each one that could be gracefully handled by a human, but where a machine would need to understand the underlying purpose of code segments, which is probably beyond the capabilities of any regexp engine.


    Dave

      Well stated davido .

      Seems I grossly understated/underestimated.

      --Chris

      #!/usr/bin/perl -Tw
      use Perl::Always or die;
      my $perl_version = (5.12.5);
      print $perl_version;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-18 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found