Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.txt

If 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.pl

which 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.txt

can be coded so concisely (or course, sed and awk could do that, but we are again comparing things that are not really comparable).


In reply to Re^3: File::Find seems grossly inefficient for performing simple file tasks by Laurent_R
in thread File::Find seems grossly inefficient for performing simple file tasks by taint

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-19 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found