The standard answer, given by Larry himself, is "Filter the shell script through Tom Christiansen." Which means that there isn't a nice converter. There may be nasty converters that I'm unaware of, but ... I'm unaware of them. :) Good luck.
UPDATE:
I couldn't find the quote to properly attribute it, but perldoc seems to know all. :)
%perldoc -q shell script
Found in /System/Library/Perl/pods/perlfaq8.pod
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. | [reply] [d/l] [select] |
#!/usr/bin/perl
use strict;
use warnings;
open (SH, '<', '/path/to/shell-script') or die "$!\n";
my $script = join("\n", <SH>);
qx/$script/;
close SH;
exit $?;
-- જલધર | [reply] [d/l] |
Hey, no cheating!Massyn, he's just piped your shell script to the shell. Sheesh. 'Course, my assumption that you want the script rewritten in Perl may be incorrect. :)
| [reply] |
I did one as a joke a few years back. It's in my CPAN directory.
The real answer is "you can't" and "it's pointless". If you just emulated the shell, you'd get no speedup. You'd have to analyze every program called by the shell to determine why it's being called. Far too much AI to be useful.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply. | [reply] |