As a follow-up to my original post, below is how the code for that same program looks now. I'm posting it here in case someone else wants to convert to modules and want to see how that would look. Thanks again for all of the advice everyone gave me. I'm still incorporating your ideas.
#!/usr/bin/perl
# program name: musings.cgi
# set libraries, scripts, & paths
use strict;
use warnings;
use library::core;
use library::musings;
use CGI qw(:standard);
my $scripts = core::get_script_variables();
my $script = $scripts->{'musing'}->{'script'};
my $top_script = $scripts->{'musings'}->{'script'};
# capture user input
my $musing_id = param('musing_id') || '';
my $ref_id = param('ref_id') || '';
# check if user data is complete
if($musing_id =~ m|\d|g) {
print redirect($script . '?musing_id=' . $musing_id);
exit;
}
# get general text for web page
my $general_text = core::get_general_text('musings',1);
my ($page_heading,$page_text,$page_image) = @{$general_text->[0]};
my $n = "\015\012";
# get web log entry
my $entries = musings::get_musings_entries($ref_id);
my $comments_cnt = musings::get_comments_cnt();
my $musing_stats = musings::get_reader_stats();
my $musing_cats = musings::get_musings_cats();
# alter heading if musing category selected
if($ref_id) {
$general_text = core::get_general_text('musings_category',1);
($page_heading,$page_text,$page_image) = @{$general_text->[0]};
$page_heading = ucfirst($musing_cats->{$ref_id}->{'ref_name'}) . $p
+age_heading;
}
# web page
core::heading($page_heading,undef,$page_text);
core::panel_start(1);
core::fiction();
core::miscellany();
core::musings_sites();
core::panel_end();
core::panel_start(2);
core::page_heading($page_heading,$page_text,undef);
# display musing entries
foreach (@$entries) {
my ($id, $ref_id, $log_head, $entry, $entry_date) = @$_;
my $cat = lc($musing_cats->{$ref_id}->{'ref_name'});
my $cnt = $comments_cnt->{$id}->{'comments_cnt'} || 'no';
my $reader_stat = $musing_stats->{$id}->{'stat'};
$entry_date = lc($entry_date);
print div({class=>'content_item'}, $n,
div({class=>'musing_abstract'}, $n,
h3(a({href=>$script . '?musing_id=' . $id}, $log_head) ), $n,
span($entry), $n ), $n,
div({class=>'item_stats'}, $n,
'posted:', $entry_date, '; readers: ', $reader_stat, '; ', $n,
a({id=>'cmt_note', href=>$script . '?musing_id=' . $id},
$cnt, 'comments'), $n,
'category: ',
a({id=>'cmt_note',
href=>$top_script . '?ref_id=' . $ref_id}, $cat) ), $n ), $n;
}
core::panel_end();
core::panel_start(3);
core::display_page_image($page_image);
musings::get_display_category_data();
core::stats_musings();
core::panel_end();
core::footer();
exit;
-Spenser
That's Spenser, with an "s" like the detective.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.