Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: subroutine help

by gjb (Vicar)
on Jun 28, 2003 at 17:26 UTC ( [id://269910]=note: print w/replies, xml ) Need Help??


in reply to subroutine help

Why should it be an CGI? Can't you get away with simply isolating the code that is common to both CGI scripts into one (or more) subroutine(s) in a module that can be called by both scripts?

Just my 2 cents, -gjb-

Replies are listed 'Best First'.
Re: Re: subroutine help
by Seumas (Curate) on Jun 28, 2003 at 19:04 UTC
    In addition to gjb's comments, if you are worried about requring too much 'stuff' that may not be needed during any one run, you could eval your commands and build your require/use list accordingly:
    if($command = 'getuser') { eval { use MyCode::Users; }; getuser(); }

    That way if you break up your code into multiple scripts and require them (as per gjb's comments), you are still only loading that which you need, dynamically. If you have a lot of subs and a lot of 'commands', this can require some precise forethought, but a little design could save you lots of resources in the long run.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-25 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found