tags:

views:

144

answers:

2

How can I convert a shell script into a Perl script?

I have a 10k line shell script and want to convert it into Perl. Is there any tool is doing that, or is there any way to do that?

+8  A: 
  1. Learn whichever shell language the script is written in
  2. Learn Perl
  3. Translate the code
David Dorward
is it answer David ?
joe
This is actually the best answer possible I'd think.
Simon Groenewolt
+12  A: 

There is no simple converter. From Perl FAQ "How-can-I-convert-my-shell-script-to-perl?"

Learn Perl and rewrite it. Seriously, there's no simple converter. Things that are awkward to do in the shell are easy to do in Perl, and this very awkwardness is what would make a shell->perl converter nigh-on impossible to write. By rewriting it, you'll think about what you're really trying to do, and hopefully will escape the shell's pipeline datastream paradigm, which while convenient for some matters, causes many inefficiencies.

Space
+1 for giving essentially the same answer as David Dorward but a) with some backup and b) some tact
AAT