Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Unix shell versus Perl

by eyepopslikeamosquito (Chancellor)
on Feb 23, 2008 at 05:01 UTC ( #669717=note: print w/replies, xml ) Need Help??


in reply to Re: Unix shell versus Perl
in thread Unix shell versus Perl

As mr_mischief has already pointed out, Perl scripts are first compiled to an internal form, ensuring syntax errors are caught at compile time rather than run time ... and considerably speeding up script execution at run time.

To give a specific example of where shell can be slow, consider the common task of running an external command recursively on all files under a given directory. In shell, you could use the find command with its -exec option, but that results in a new process being created for every file. I've measured cases traversing thousands of files where such an approach proved to be hundreds of times slower than using Perl's File::Find module in harness with a Perl function performing the work of the external command. The performance difference is especially noticeable when the external command doesn't do much work. Of course, the way to solve this performance problem in shell is to use find in harness with xargs, but there are portability pitfalls for the unwary, namely when the filenames might contain spaces or other unusual characters -- as indicated in this response to a gnat use.perl.org journal entry.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://669717]
help
Chatterbox?
[trippledubs]: stevie are you still ignoring me
[trippledubs]: either way; sorry.
[trippledubs]: Someone please tell Steveie that I humbly and sincerely apologize
[trippledubs]: i'll try again later. wink

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-03-27 03:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (315 votes). Check out past polls.