Hi there. I'm sure PHP must seem like a toy language to most perl developers. But when you're used to PHP, perl can sure seem unnecessarily complex...
I'm trying to write a simple global to do the following:
1) Check if the logged in user has any records in the "events" table.
2) If he does, return a list of the titles of those events.
Here's what I've got:
use GT::SQL;
my $tags = shift;
my $user = $tags->{Username};
my $db = new GT::SQL '/path/to/admin/defs';
my $table = $db->table ('events');
my $output = "";
my $results = $table->query ({Owner_userid => $user});
if ($results) {
foreach my $result (@$results) {
$output .= "<br>$result[2]";
}
}
return $output;
}
I'm sure that's not the most direct way to accomplish this, but it seems like it's close to working.
Nonetheless, here's the error I'm getting:
Global symbol "@result" requires explicit package name at (eval 15) line 12. Unable to compile 'events_list'. Reason: at /path/to/admin/Dbsql/Home.pm line 1505.
I would be very grateful if someone could tell me what I'm doing wrong. Thanks!
Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
I'm trying to write a simple global to do the following:
1) Check if the logged in user has any records in the "events" table.
2) If he does, return a list of the titles of those events.
Here's what I've got:
Code:
sub { use GT::SQL;
my $tags = shift;
my $user = $tags->{Username};
my $db = new GT::SQL '/path/to/admin/defs';
my $table = $db->table ('events');
my $output = "";
my $results = $table->query ({Owner_userid => $user});
if ($results) {
foreach my $result (@$results) {
$output .= "<br>$result[2]";
}
}
return $output;
}
I'm sure that's not the most direct way to accomplish this, but it seems like it's close to working.
Nonetheless, here's the error I'm getting:
Global symbol "@result" requires explicit package name at (eval 15) line 12. Unable to compile 'events_list'. Reason: at /path/to/admin/Dbsql/Home.pm line 1505.
I would be very grateful if someone could tell me what I'm doing wrong. Thanks!
Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund