Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

v1.11 -> Splitting .pm modules

Quote Reply
v1.11 -> Splitting .pm modules
I know that in the NEXT GENERATION version of Links SQL, the program is more modular than it is in current working versions...I don't anticipate upgrading until there is a stable release of the NEXT GENERATION...and I am attempting to modularize v.1.11.

What I am attempting to do is create separate *_HTML_Templates.pm files for different sections of my site (job postings, resume postings, links, reviews, etc.). Yet I am running into many problems in terms of UNKNOWN TAGS (yes, I have read the three relevant Threads about this, but does not really relate to my challenge).

Here is what I have done:

1) Created a .pm file called Globals.pm that stores the "global" tags to be used across the different sections.

2) Created the following PM files:

* Career.pm

- Contains global variables to be used in the job and resume posting sections of my site.

* Career_HTML_Templates.pm

- Contains career "global" tag definitions and subroutines to be used in the career scripts.

* Custom.pm

- Contains global variables to be used across all scripts. (e.g., $CUSTOM{new_img}.

* Forum.pm

- contains global variables for the forum.cgi scripts.

* Forum_HTML_Templates.pm

- contains global tag definitions and subroutines to be used in the forum scripts.

* Globals.pm

- contains global tag definitions to be used across all scripts.

* Members.pm

- contains global variables for user access scripts.

* Members_HTML_Templates.pm

- contains global tag definitions and subroutines to be used in user scripts (e.g., login.cgi, logout.cgi, etc.)

* Links.pm

- similar to the default version, yet most of the variables have been moved to the Custom.pm file.

* Links_HTML_Templates.pm

- contains global variables for link based scripts and subroutines for those scripts.

3) Edited some of the scripts as test scripts to include the appropriate modules.

4) Edited subroutines in the *_HTML_Templates.pm files to include:



The second GLOBAL hash is for that particular module file, like ╩REERGLOBALS. I also edited the EXPORTER codes at the top of each *_HTML_Templates.pm file to include %GLOBALS %*GLOBALS.

Yet in most of the test scripts...I get UNKNOWN TAGS that are defined in the Globals.pm file. I believe the crux of my problem stems from the illogical codes I am using in the Globals.pm module.

Here are the relevant codes:


package Links::Globals;
# ===============================================================
use strict;
use vars qw(@ISA @EXPORT %USERS %GLOBALS);
use Carp;
use Socket;
use lib '..';
use Links::Career;
use Links::Custom;
use Links::DBSQL;
use Links::DB_Utils;
use Links::Forum;
use Links::Links;
use Links::Members;
use Exporter ();
@ISA = qw(Exporter);
@EXPORT = qw/&escape &send_error &load_user


build_addjobs_url => $CAREER{build_addjobs_url},
build_addres_url => $CAREER{build_addres_url},
build_career_url => $CAREER{build_career_url}.
build_deljobs_url => $CAREER{build_deljobs_url},
build_delres_url => $CAREER{build_delres_url},
build_modjobs_url => $CAREER{build_modjobs_url},
build_modres_url => $CAREER{build_modres_url},
build_sendjobs_url => $CAREER{build_sendjobs_url},
build_submitres_url => $CAREER{build_submitjobs_url},
awardimg => $CUSTOM{awardimg},
back => $ENV{'HTTP_REFERER'},
banner => \&Links::DB_Utils::insertadvert,
body => $CUSTOM{body},
bot_table => $CUSTOM{bot_table},
emailimg => $CUSTOM{emailimg},
errorimg => $CUSTOM{errorimg},
font => $CUSTOM{font},
fonterror => $CUSTOM{fonterror},
fontlg => $CUSTOM{fontlg},
fontspec => $CUSTOM{fontspec},
fontwhite => $CUSTOM{fontwhite},
framebody => $CUSTOM{framebody},
gthn => $CUSTOM{gthn},
hideimg => $CUSTOM{hideimg},
hidecat => $CUSTOM{hidecat},
logo => $CUSTOM{logo},
lthn => $CUSTOM{lthn},
mnbody => $CUSTOM{mnbody},
nbsp => $CUSTOM{nbsp},
new1img => $CUSTOM{new1img},
new3img => $CUSTOM{new3img},
new7img => $CUSTOM{new7img},
privateimg => $CUSTOM{privateimg},
redirect => \&Links::DB_Utils::get_category_redirect,
redirect_mncat => \&Links::DB_Utils::get_mncategory_redirect,
static => \&Links::DB_Utils::get_category_static,
revimg => $CUSTOM{revimg},
showimg => $CUSTOM{showimg},
showcat => $CUSTOM{showcat},
smfont => $CUSTOM{smfont},
smfontwhite => $CUSTOM{smfontwhite},
smfont2 => $CUSTOM{smfont2},
smfontwhite2 => $CUSTOM{smfontwhite2},
time => \&Links::DBSQL::get_time,
titlefont => $CUSTOM{titlefont},
titlewhitefont => $CUSTOM{titlewhitefont},
top5img => $CUSTOM{top5img},
top_table => $CUSTOM{top_table},
totallinks => \&Links::DB_Utils::get_totallinks,
totalcats => \&Links::DB_Utils::get_totalcats,
totalrev => \&Links::DB_Utils::get_totalrev,
update_img => $CUSTOM{update_img},
build_extension => $CUSTOM{build_extension},
catlist => \&Links::DB_Utils::get_category_drop,
date => \&Links::DBSQL::get_page_date,
build_addpost_url => $FORUM{build_addpost_url},
build_delpost_url => $FORUM{build_delpost_url},
build_editpost_url => $FORUM{build_editpost_url},
build_forum_url => $FORUM{build_forum_url},
build_reply_url => $FORUM{build_reply_url},
build_add_url => $LINKS{build_add_url},
build_addcat_url => $LINKS{build_addcat_url},
build_alpha_url => $LINKS{build_alpha_url},
build_addbanner_url => $LINKS{build_addbanner_url},
build_admin_url => $LINKS{build_admin_url},
build_award_url => $LINKS{build_award_url},
build_alpha_url => $LINKS{build_alpha_url},
build_bookmarks_url => $LINKS{build_bookmarks_url},
build_check_url => $LINKS{build_check_url},
build_cool_url => $LINKS{build_cool_url},
build_deadlink_url => $LINKS{build_deadlink_url},
build_dellinks_url => $LINKS{build_dellinks_url},
build_delacct_url => $LINKS{build_delacct_url},
build_delrev_url => $LINKS{build_delrev_url},
build_detail_url => $LINKS{build_detail_url},
build_editor_url => $LINKS{build_editor_url},
build_editor_page_url => $LINKS{build_editor_page_url},
build_extrate_url => $LINKS{build_extrate_url},
build_feedback_url => $LINKS{build_feedback_url},
build_graph_url => $LINKS{build_graph_url},
build_jump_url => $LINKS{build_jump_url},
build_keylogger_url => $LINKS{build_keylogger_url},
build_linkdetail_url => $LINKS{build_linkdetail_url},
build_linkmailer_url => $LINKS{build_linkmailer_url},
build_listcats_url => $LINKS{build_listcats_url},
build_listlinks_url => $LINKS{build_listlinks_url},
build_listrev_url => $LINKS{build_listrev_url},
build_listst_url => $LINKS{build_listst_url},
build_listsod_url => $LINKS{build_listsod_url},
build_maintain_url => $LINKS{build_maintain_url},
build_modify_url => $LINKS{build_modify_url},
build_modrev_url => $LINKS{build_modrev_url},
build_nominate_url => $LINKS{build_nominate_url},
build_new_url => $LINKS{build_new_url},
build_newreviews_url => $LINKS{build_newreviews_url},
build_quote_url => $LINKS{build_quote_url},
build_rate_url => $LINKS{build_rate_url},
build_ratings_url => $LINKS{build_ratings_url},
build_recsite_url => $LINKS{build_recsite_url},
build_redirect_url => $LINKS{build_redirect_url},
build_remotesend_url => $LINKS{build_remotesend_url},
build_reply_url => $LINKS{build_reply_url},
build_review_url => $LINKS{build_review_url},
build_reviewdetail_url => $LINKS{build_reviewdetail_url},
build_revmailer_url => $LINKS{build_revmailer_url},
build_revpass_url => $LINKS{build_revpass_url},
build_search_url => $LINKS{build_search_url},
build_sendlink_url => $LINKS{build_sendlink_url},
build_sendreview_url => $LINKS{build_sendreview_url},
build_survey_url => $LINKS{build_survey_url},
build_delacct_url => $MEMBERS{build_delacct_url},
build_login_url => $MEMBERS{build_login_url},
build_logout_url => $MEMBERS{build_logout_url},
build_mailer_url => $MEMBERS{build_mailer_url},
build_maintain_url => $MEMBERS{build_maintain_url},
build_online_url => $MEMBERS{build_online_url},
build_password_url => $MEMBERS{build_password_url},
build_privmailer_url => $MEMBERS{build_privmailer_url},
build_signup_url => $MEMBERS{build_signup_url},
build_userdetail_url => $MEMBERS{build_userdetail_url}

Any thoughts or suggestions for properly modularizing v.1.11 would be greatly appreciated! Smile

I will be out of town for the next few days, but hopefully, I will get some reponses to review by the time I get back.

Thanks in advance.


Eliot Lee
Quote Reply
Re: v1.11 -> Splitting .pm modules In reply to
Ok, I'm a bit confused, since I'm not sure how you are breaking up the HTML_*.pm file, and I'm not sure if the %GLOBALS or the %*GLOBALS tags are giving you the errors, but if you are doing something like use GLOBALS at the top of the file, you probably need to also define the %GLOBALS in the vars statement at the top of each of those files.

What I would try, is in the various files, import the %GLOBALS at the top, then ADD TO IT, by adding the new variables to it.

Don't do an assignment %GLOBALS = {....} or you overwrite your values, you have create a list of the tags and assign them:

$GLOBALS{custom_tag_1} = value_1;
$GLOBALS{custom_tag_2} = value_2;
$GLOBALS{custom_tag_3} = value_3;
$GLOBALS{custom_tag_4} = value_4;

Etc...that way, you have one large hash of all the "globals" and you'll know where the definition problem is.

PUGDOG« Enterprises, Inc.
FAQ: http://postcards.com/FAQ

Quote Reply
Re: v1.11 -> Splitting .pm modules In reply to
Thanks, pugdog...I understand the logic behind what you are saying...but if I understand you correctly, I would have to copy all the "Globals" codes into ALL the *_HTML_Templates.pm files I create, which is what I am attempting to avoid...

And yes...I am attempting to modularizing the subroutines used in different sections of my site that rely on Links SQL. So, I am attempting to separate or break up the HTML_Templates.pm files.


ALL subs used in the forum.cgi script go in the FORUM_HTML_Templates.pm.

ALL subs used in the job and resume posting scripts will go in Career_HTML_Templates.pm.


Eliot Lee
Quote Reply
Re: v1.11 -> Splitting .pm modules In reply to
Yes and no. Look at how the

use vars qw/$CFG $USER/;

Statement in the new links works.

Pull your globals out into another file, GLOBALS.pm. Declare %GLOBALS to be
global to the various routines.



That should pull them into whatever file you are using, and make them
global to that file that use'd them.

PUGDOG« Enterprises, Inc.
FAQ: http://postcards.com/FAQ

Quote Reply
Re: v1.11 -> Splitting .pm modules In reply to
Hmm...okay...more food for thought...

Thanks, pugdog! I will play around with it some more...I really want to avoid copying the %Globals across all the *_HTML_Templates.pm file.


Eliot Lee