OK, I bow humble before thee, honorablest Perl monks:

What is this 'EOUsage' in the code below? And what is that funky '$0' variable? I obviously didn't find it too helpful, but here's what the perldoc says about $0:

Contains the name of the file containing the Perl script being executed. On some operating systems assigning to ``$0'' modifies the argument area that the ps(1) program sees. This is more useful as a way of indicating the current program state than it is for hiding the program you're running. (Mnemonic: same as sh and ksh.)

I'm guessing, from the way it looks, it automatically comments out the lines but how exactly does it work? Here's the subroutine code I have questions on, edited for brevity:

sub usage { $0 =~ s#.*/##; print STDERR <<EOUsage; Usage: $0 [options] where options are: [-v ] | [--version ] [more of the same...deleted...deleted...deleted...deleted] [-db <n> ] | [--debug <n> ] [-pm/+pm ] | [--preformat-marker / --nopreformat-marker ] More complete explanations of these options can be found in comments near the beginning of the script. EOUsage # [-T <t>:<r> ] | [--tag <tagname>:<regexp> ] }

Any other insights into what this subroutine is doing is much appreciated. Thanks!

2001-03-29 Edit by Corion : Changed title


In reply to Here document syntax, what is $0 (was: Newbie need a clue) by nysus

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.