Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Perl converters

by Wyman G (Initiate)
on Jun 18, 2004 at 18:59 UTC ( #368030=perlquestion: print w/ replies, xml ) Need Help??
Wyman G has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know is there is a tool/utlity that will convert ksh to perl. I have a lot of code I would like to convert from the korn shell.

Comment on Perl converters
Re: Perl converters
by pbeckingham (Parson) on Jun 18, 2004 at 19:06 UTC

    How about merlyn's sh2perl? It may help you somewhat.

Re: Perl converters
by Corion (Pope) on Jun 18, 2004 at 19:11 UTC
      Thanks, I will look these references up.
Re: Perl converters
by tachyon (Chancellor) on Jun 19, 2004 at 06:21 UTC

    If you look up the FAQ you will note it is not optimistic about the benefits. If your shell scripts work why not leave them. If you want to convert them to perl it is a good oportunity to learn about the language with some useful small widgets.

    cheers

    tachyon

Re: Perl converters
by CountZero (Bishop) on Jun 19, 2004 at 14:48 UTC
    As the faq indicates, you probably gain neither speed nor resources by a machine-translation.

    Rather you should ask yourself what your scripts do and see if there are any benefits to recode them in Perl (or any other language for that matter). Of course if your intended goal is simply to learn Perl, then studying machine-translations of shellscripts into Perl is probably not the way to go. Such automated translations will have little or no "educational value". Either they are simple one-on-one translations which will not show the strength of the language, or they will be so highly optimised as to be virtually unreadable in all but the simplest of cases.

    Far better to buy a good book on programming and start coding away.

    Hanging out on PerlMonks wont be bad either!

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      I know of one case where a badly written (that's probably the reason) shell script was replaced by a Perl script with a speed gain of a factor of 1275. Not per cent! YMMV

      -Theo-
      (so many nodes and so little time ... )

        If your shell script uses a lot of "expensive" external commands, may be even in a loop and you can replace that by some internal commands of Perl, the speed gain would be enormous. However, if you "machine translate" such script into Perl by calling exactly the same external commands (through backticks or system), you will be worse off than before.

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-12-21 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls