nysus has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Newbie need a clue
by kschwab (Vicar) on Mar 29, 2001 at 07:02 UTC | |
|
Re: Newbie need a clue
by damian1301 (Curate) on Mar 29, 2001 at 06:52 UTC | |
by redmist (Deacon) on Mar 29, 2001 at 10:14 UTC | |
by damian1301 (Curate) on Mar 30, 2001 at 01:08 UTC | |
|
Re: Newbie need a clue
by physi (Friar) on Mar 29, 2001 at 12:23 UTC | |
|
Re: Here document syntax, what is $0 (was: Newbie need a clue)
by merlyn (Sage) on Mar 29, 2001 at 19:48 UTC | |
|
Re: Newbie need a clue
by nysus (Parson) on Mar 29, 2001 at 07:26 UTC | |
by voyager (Friar) on Mar 29, 2001 at 07:30 UTC | |
by nysus (Parson) on Mar 29, 2001 at 07:33 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |