in reply to Re^2: Has anyone attempted to create a PHP to Perl converter?
in thread Has anyone attempted to create a PHP to Perl converter?
There’s no doubt, of course, that valid PHP can be parsed, for syntax checking and so-on, and that once the source has been reduced to an abstract-syntax tree (AST) form, some of those AST constructs could be expanded into Perl. The languages are in many ways very similar. You might be able to do such a thing, say, in an editor-macro for a very smart editor.
If you look beyond the superficial, though, you start getting into some much thornier problems. For example, in the PHP system, “everything is compiled-in,” and is called by means of (hundreds of ...) functions. Database access, for example, is implemented in that way. In the Perl system, per contra, we have DBI. Now you are going to have to develop a way for the translated Perl code to continue doing things “the PHP way.” Suddenly, your problem has become quite a bit more complicated, and pretty soon “diminishing returns” are going to be a factor. And then, there are the ideas that simply do not exist at all in Perl, such as the intermingling of HTML and PHP in a file, which was a founding concept of PHP.