Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: where do you put your subs

by abaxaba (Hermit)
on Mar 08, 2002 at 06:38 UTC ( #150242=note: print w/ replies, xml ) Need Help??

in reply to where do you put your subs

This is simply a matter of taste, IMHO. But, I have no "main" code, per se. rather..

#!perl use strict; use Modules; main(); sub main { #main algorithm, calls to other subs } sub1 {#sub code} sub2 {#sub code} etc..

I find this method to be extremely helpful in having variables with a limited scope. Just say "NO" to globals.

Comment on Re: where do you put your subs
Download Code
Replies are listed 'Best First'.
Re: Re: where do you put your subs
by ajwans (Scribe) on Mar 08, 2002 at 11:18 UTC
    I like to do
    #!/usr/bin/perl -w exit main(); sub main { ... return (0); }
    Maybe I'm just a C programmer at heart.

    1. dude, what does mine say?
    2. "sweet", what about mine?
    3. "dude", what does mine say?
    4. GOTO 2
      The code-flow is not really logical: why do you exit before performing your tasks? Is there any reason to have the exit statement before the sub declaration?

      And real C programmers at heart write some for (;;) instead of ... 4 GOTO 2 :)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://150242]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2016-02-07 13:45 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (253 votes), past polls