Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
As to why options-first is the standard, it's because in the formative days of Unix, memory wasn't cheap. Neither were the CPU cycles to make a copy of a list of 500 files, or even just to go through them. Unix was exceptional in allowing long command lines, which glob() would fill up in the shell.

It was never necessary, however, to go through the list of files twice. You just process the options and then march on through the list, processing them one at a time. Just once. So long as the options come first, it's a one pass algorithm. If you allow the options to come later, you always have to do an earlier pass to find them, because they can change how you process files earlier in the list.

In the present age of cheap memory and CPU cycles to burn, options-first a leftover convention, now become, ahem, one of the standards. It helps you know where to look for things. (Except when people are following other standards.)

Note that many of the organized and consistent ways of doing things that we all like about Unix come not just from the insight and self-discipline of our technical ancestors, but from external constraints of time and space (memory space). Unix itself started as a reaction to MIT's MULTICS project, the OS that could do most anything, if you could wait a very long time. (That's where the Unix name came from.)


In reply to Re: Why is it good practice for a cli script to take switch args before file list? by rodion
in thread Why is it good practice for a cli script to take switch args before file list? by leocharre

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 contemplating the Monastery: (3)
As of 2024-04-25 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found