Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OOP with Perl

Status
Not open for further replies.

SPrelewicz

Programmer
Jul 16, 2001
124
US
I've been using Perl for a bit, but am just starting to use it with objects. I have a code snippet I'd like critiqued to see if I'm on the right track or havent got a clue. I am using CGI::App, but not sure that should matter. Anyway, here's the code:

sub show_form {
my $self=shift;
my $dbh=$self->param('dbh');

my $template=$self->load_tmpl('/HUBNET/stats_front.tmpl');
my $recent_reports=$self->load_recent();



}

sub load_reports {
my $self=shift;
my $dbh=$self->param('dbh')

# Get the list of recent reports run from the database
unless (exists($self->{__RECENT_REPORTS})) {
$self->{__RECENT_REPORTS} = {};

my $sth=$dbh->prepare("SELECT * FROM recent_reports ORDER BY date LIMIT 5");
$sth->execute();

while (my $row=$sth->fetchrow_hashref()) {
$self->{__RECENT_REPORTS}->($row->{report_id})=$row;
}
}

return $self->{__RECENT_REPORTS};

}

It's the start of a stat reporting program. One aspect of the program is that it will show the 5 most recently run reports that are stored in a db. What I want to know is that these two functions follow correct OO principals.

Thanks for the advice,

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top