|
Posted by Bill H on May 21, 2008, 7:02 am
Please log in for more thread options
> I'm trying to modularise out web-site, it's mostly CGI (perl) apart from
> two or three static HTML pages. What I want is a perl script which calls
> a header, top-bar navigation, left panel, page body, right panel. And
> each of those sections to be separate perl programs which can be edited
> independantly of the main 'index.cgi'. =A0It is a requirement that I can
> pass some info (variables, arrays, hashes) between the main and each of
> the 'modules'.
>
> I'm not entirely certain that modules are what I want. I've looked at
> 'require', and this works well for static html using here-doc, but I
> need to run perl to act upon certain variables from the main program.
>
> Reading perldoc perlmod doesn't help much, it talks mostly about
> scoping. If modules are where I should be going, I need some info on how
> to write my own.
>
> I've got to where I am from starting to use WordPress, and building my
> own theme, the main part of the code works as above, very simple 'main',
> calling the relevant parts which stand alone, and it works very
> well, and is very simple to maintain. The only problem is it's PHP, and
> I'm far from profficient (not that I'm any good with perl, I'm just much
> further along the perl road).
>
> Thank you for any suggestions or pointers you can give with regard to
> the above.
>
> =A0 =A0 =A0 =A0 Justin.
>
> --
> Justin C, by the sea.
Though you description is a little vague, I believe what you mean by
modules is, should all the code that handles left panel be in one
module, page body in another etc and then have a main program that
"requires" the modules based on what is needed. If this is what you
mean, I have used this method many times since there was a lot of code
that they all had in common in the main program. On the other hand, if
there is not a lot of code they have in common and they all make use
of various "subs" you can go the other way and put all your common
code in a "required" module and then have different program for each
part of the page, I have done this too.
My experience has been using the latter with different programs and a
common module (or modules) is easier to work with and expand on (ie
add something to the web site, create a new program for it using the
common stuff and custom code). Also you do not have to worry if your
new stuff effects the old stuff as you would in the former method of a
single program and mutliple modules.
Bill H
|