kehansen has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Scripts with only sub-routines?
by Burak (Chaplain) on Mar 24, 2008 at 20:17 UTC | |
See debugger.perl.org for more informartion on the debugger. | [reply] [d/l] |
|
Re: Scripts with only sub-routines?
by kyle (Abbot) on Mar 24, 2008 at 20:29 UTC | |
Some details would help here. Without having a look at what you have, I can only guess. Modules that you use can execute code. A sub BEGIN is actually a block that runs without being called, if you have any of those. See perlmod for more info and other blocks that might act this way. You speak of some variable settings. Something like "my $host = `hostname` is actually executing the hostname shell command (note the backticks, not single quotes). | [reply] [d/l] [select] |
by Fletch (Bishop) on Mar 24, 2008 at 20:51 UTC | |
Modules that you use can execute code Exactly; and the code they execute may not be immediately obvious.
Just imagine what chaos one could foment if you changed that to (say) rot13 the prefix before picking what to run, or generated the prefix based on the phase of the moon . . . :)
The cake is a lie. | [reply] [d/l] |
|
Re: Scripts with only sub-routines?
by moritz (Cardinal) on Mar 24, 2008 at 20:31 UTC | |
use Module; loads that module, and calls the sub import in that module. You can do things there. (This happens at compile time. When you have a sub called BEGIN, INIT, CHECK or END it is automatically invoced, either at compile time, after the program has terminated (or more obscure times. See perlsub for more details). If you're new to perl (which is not spelled PERL btw.) it might be that you don't recognize a sub call even though there is one. In many cases just the name of the sub without any parenthesis is enough to call it. | [reply] [d/l] [select] |
by kehansen (Novice) on Mar 24, 2008 at 21:10 UTC | |
| [reply] |
|
Re: Scripts with only sub-routines?
by apl (Monsignor) on Mar 24, 2008 at 20:26 UTC | |
| [reply] |
by kehansen (Novice) on Mar 24, 2008 at 20:44 UTC | |
| [reply] [d/l] |
by Fletch (Bishop) on Mar 24, 2008 at 20:55 UTC | |
You're the unfortunate victim of poor formatting. It's calling the graph sub several times for each hostname in @host (kind of poorly named; a plural name @hosts would read better, but I digress). You just can't see the flow because someone's gotten the indentation out of whack. In cases such as this perltidy is your friend.
The cake is a lie. | [reply] [d/l] [select] |
by kehansen (Novice) on Mar 24, 2008 at 21:13 UTC | |
|
Re: Scripts with only sub-routines?
by NetWallah (Canon) on Mar 25, 2008 at 00:24 UTC | |
If you will be doing this on a regular basis, I recommend you upgrade to cacti (Will take a considerable learning curve for installation and use, but well worth it). "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom | [reply] |
|
Re: Scripts with only sub-routines?
by Spidy (Chaplain) on Mar 24, 2008 at 22:01 UTC | |
| [reply] |