in reply to RFC: UNIX shell to Perl converter

The interesting and rewarding parts of shell to Perl conversion (for me) are mostly taking the multiple (and often unnecessary) calls to external programs and replacing them with fast Perl constructs.

Here you are suggesting that using a shell and calling other program is necessary (much) slower than doing it all in Perl. I beg to differ. Sure, if all your program is doing is calling a different program hundreds of time, and each time it just takes a fraction of a second to run, the shell loses because of the forking overhead.

But any Perl program starts with a backstart - the start up time of a Perl program is larger than of a shell script. And the shell typically calls utilities that have been written in C, and have been optimized for decades. Your systems' 'grep' and 'sort' will typically be much faster that the Perl equivalents - the Perl equivalents pay the price of being more powerfull, and having to deal with Perl variables.

Replies are listed 'Best First'.
Re^2: RFC: UNIX shell to Perl converter
by cdarke (Prior) on Oct 10, 2006 at 20:14 UTC
    Good point, and I agree, but it's a question of scale. When these programs are called in loops (and often are) it is not unusual to get a script forking hundreds or thousands of child processes. I agree that a well written shell script can be more efficient than a Perl program, particularly when the Perl loads modules. If you have such a script I doubt it would be a candidate for conversion.