[kamloops-pm] Hello

Anthonyj anthonyj at jonathan.abda.net
Thu Oct 9 14:20:14 CDT 2003


Thankyou, I wasn't expecting such quick replies.
Another list member had similar things to say, but sent them directly to me
by accident, and asked me to bounce them to the list, so here it is.

(in a moment)
I'll take your advice, except in one place, the $post_data value, didn't
need to have my in front of it in the first place.  Guess I wasn't paying
attention to what 'my' actually did.

You are wise in the ways of perl, I am not, I shall join you.  Thanks.

The following origionally from <smoky at flogged.net>

a couple small changes. the 'my $row' is cool since it's only to be used in
the while loop, but it's a good habit to delare/define your variables at the
beginning of the function/sub. you should also 'use strict;', it helps tons.
it'll complain about stuff like '$row->{ID}' and prefers "$row->{'ID'}", but
it can save you debugging time. the -w option (if applicable), is great. or
just set ^W.

sub display_goal_posts
{

#get discussion for current goal
our ($sth, $SQL);
my (%goal_posts, @table_template, %replace, $post_data);


$SQL="SELECT * FROM goal_posts WHERE Project = '1' and Goal = '2'";
$sth=getRS($SQL, $dbh);

while (my $row = $sth->fetchrow_hashref() )
{
$goal_posts{ID} = $row->{ID};
$goal_posts{Goal} = $row->{Goal};
$goal_posts{Text} = $row->{Text};

open (HTML,"<" . $goal_post) or print "Cannot open $goal_post\n";
@table_template = <HTML>;
close (HTML);

$replace{POST_TEXT} = $goal_posts{Text};

$post_data .= join("\n", @table_template);
$post_data =~ s|<!--%(.*?)%-->|$replace{$1}|gs;
}

#print $post_data;
return $post_data;

}

________________________________________________
MailServer powered by
SilverServers Inc.
Visit us at http://www.SilverServers.com



More information about the kamloops-pm mailing list