joe
joe

Reputation: 35077

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

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?

Upvotes: 2

Views: 1593

Answers (2)

Space
Space

Reputation: 7259

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.

Upvotes: 12

Quentin
Quentin

Reputation: 943108

  1. Learn whichever shell language the script is written in
  2. Learn Perl
  3. Translate the code

Upvotes: 9

Related Questions