Consider:

$ mkdir ./-e $ cat >./-e/test #!/usr/bin/perl -w die "It ran!"; __END__ $ chmod a+x ./-e/test $ ./-e/test It ran! at ./-e/test line 2. $ -e/test Search pattern not terminated at -e line 1. $
So the practice does prevent one problem. Not one you are likely to run into, but a problem still.

For that last command, perl gets executed with a command line that looks like:

perl -w -e/test
(at least on some operating system / shell combinations) and it doesn't know that "-e/test" is the name of a script file instead of the "-e" option asking it to interpret the code "/test" (which causes it to complain about not finding the terminating "/" for that pattern match).

I could envision some operating systems filling in the "--" for you such that including your own "--" would cause perl to report:

Can't open perl script "--": No such file or directory
though. So I'm not sure what to advocate at this point.

                - tye

In reply to Re: Using -- to terminate switch processing (good point) by tye
in thread Using -- to terminate switch processing by thelenm

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.