in reply to Here document syntax, what is $0 (was: Newbie need a clue)
The quoted text seems lucid to me. Perhaps I can rephrase a little ? If this script exists on a unix box as /usr/local/bin/myscript, $0 could contain one of several values, depending on how it was called:
| How script was started | Contents of $0 |
|---|---|
| $ myscript | myscript |
| $ /opt/local/bin/myscript | /opt/local/bin/myscript |
| $ cd /opt/local/bin;./myscript | ./myscript |
The following bit: $0 =~ s#.*/##; is a regex that strips everything from the front of $0 until it reaches the last "/" character. So, if the script is named myscript, after this regex is run against $0, $0 would contain myscript, regardless of how it was called.
|
|---|