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 s开发者_JAVA百科hell script and want to convert it into Perl. Is there any tool is doing that, or is there any way to do that?
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.
- Learn whichever shell language the script is written in
- Learn Perl
- Translate the code
精彩评论