Heya Andrew,
You said ---> Lately I have been trying to factor out
common code and make things more modular. So I now use
only one subroutine to generate pages. I just pass
this sub the appropriate parameters (template, values,
etc.) I find that it's easier to expand/update the
program this way. ---
This is what I am looking for, but I dont quite
understand how it is done. Do you have an example?
And, yes, my host is running mod_perl. I know a bit
about how it "caches" a script. I'm still learning
how it is done though...
Thanks,
Will
---------------------------------------------
--- Andrew Brosnan <andrew@...> wrote:
> On 11/11/02 at 6:42 AM, self_deprecated@...
> (Will) wrote:
>
> Hello Will
>
> > I have a code design idea, but I am not sure if it
> is
> > all that efficient, so I wanted to ask if there is
> a
> > better way to do what I am thinking.
> >
> > Suppose I have a script, like a bulletin board,
> which
> > I know will produce five webpages:
> 1.)view_posts_list,
> > 2.) read_posts, 3) reply_2_post, 4.) confirm_post
> and
> > 5.) error_mssg. Currently, I look at it like I
> have
> > at least five subtroutines - one for each page -
> plus
> > any other subroutines that may be necessary.
>
> I used to do things this way. Lately I have been
> trying to factor out
> common code and make things more modular. So I now
> use only one
> subroutine to generate pages. I just pass this sub
> the appropriate
> parameters (template, values, etc.)
>
> I find that it's easier to expand/update the program
> this way.
>
> > Basically, I just use perl to initialize the
> > variables, and then insert those values into the
> HTML
> > via the template tags.
>
>
> >
> > The concern I am trying to lead up to here is that
> the
> > headers and footers in each "page"/subroutine are
> the
> > same from page to page. If I understand
> correctly,
> > all this stuff gets compiled at runtime The
> script
> > would probably be more efficient if I were able to
> > somehow "factor out" those common areas into the
> main
> > logic (main logic = driver) of the script, but I
> am
> > not sure how to do that. Can anyone explain a way
> to
> > handle this?
>
>
> Does the above help?
>
> If the script is not calling a sub (ie not
> outputting a particular page)
> I wouldn't be too concerned. Perl will compile it
> very fast. Then at
> runtime, it's just not being used; which is where
> any slowdown would
> probably occur.
>
> Try testing it with the benchmark module. Sometimes
> I agonize over
> efficiency problems that don't actually exist :-)
>
> If efficiency is a *big* concern, have you
> considered mod_perl?
>
>
> Andrew
__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2
|