Click here to get back home

Do I want modules? If not, what?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Do I want modules? If not, what? Justin C 05-21-2008
Posted by Justin C on May 21, 2008, 5:54 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'. It 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.

        Justin.

--
Justin C, by the sea.

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

Posted by Justin C on May 21, 2008, 7:37 am
Please log in for more thread options
>
[snip]

> 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.

That sounds quite interesting. And, I think it's more like WordPress
does it, IIRC (not that I want to necessarily mimic their method). I'll
have a play around, thanks for the suggestion.

I do need to get my head around writing my own modules at some point
though!

        Justin.

--
Justin C, by the sea.

Similar ThreadsPosted
modules, modules, modules November 26, 2005, 3:33 am
Using CGI and GD modules December 2, 2005, 12:46 pm
Modules using each other January 31, 2006, 4:50 pm
Modules February 15, 2006, 3:47 am
new modules April 7, 2006, 4:13 pm
Using Modules once April 10, 2007, 4:53 pm
perl modules August 8, 2004, 5:49 am
Perl PDF modules - help please August 11, 2004, 2:31 pm
Using pod2html for all modules? May 5, 2005, 12:03 am
installing modules? September 29, 2005, 9:18 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap