in reply to Re^2: File::Find seems grossly inefficient for performing simple file tasks
in thread File::Find seems grossly inefficient for performing simple file tasks
Hmmm, that type of comparison does not really make sense to me.
If I want to find all the lines that contains the letters "ab" in a file, using shell script, I can just write:
grep ab file.txtIf I want to do that in a Perl one-liner, there is just no way I can do that in just 8 characters plus the name of the file. Just the "perl -e " sequence has 8 characters, and I haven't even started to give the code of my Perl script. The script could be as short as something like this:
perl -ne 'print if /ab/' file.txt(Maybe someone will find some way of doing it shorter, but that's not the point.)
There is just no way a Perl program could be as simple (as concise, as short) as a simple shell command, but it makes no sense to compare them. A shell command may contain hundreds or thousands of code source lines. If you go this way, I could also include all the code that I want or need in an x.pl file and then say that:
grep ab file.txt can be replaced by the following: x.plwhich shows that Perl is far more concise than the shell or almost pretty anything else.
I should add that I don't know many languages where something like this:
perl -ne 'print if /ab/' file.txtcan be coded so concisely (or course, sed and awk could do that, but we are again comparing things that are not really comparable).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: File::Find seems grossly inefficient for performing simple file tasks
by taint (Chaplain) on Apr 26, 2013 at 22:14 UTC | |
by Laurent_R (Canon) on Apr 27, 2013 at 10:37 UTC |