Data::Dumper will show you the structure of the data returned by
selectall_arrayref as used above:
use Data::Dumper;
die Dumper $rows;
__DATA__
$VAR1 = [
{
'locked' => 'no',
'stick' => 'quux',
'last_update' => '2004-05-17 00:24:28',
'name' => 'qux',
'post' => 'foo',
'author' => 'baz',
'last_updated_by' => 'joe',
'view' => 'bar',
'id' => '1'
}
];
This data is suitable for use as a
<TMPL_LOOP> in a template prepared for
HTML::Template. It is a reference to an array of hashes. Each hash holds the data from one record in your dataset. The keys of the hash are the table columns specified in your SELECT statement.
To remove profanity from each record's "post" field, you can use something like the following:
use Regexp::Common 'RE_profanity';
+
foreach my $row ( @$rows ) {
# $row is a hash reference containing the
# data from a single record
$row->{post} =~ s/$RE{profanity}/[censored]/g;
}
+
use Data::Dumper;
die Dumper $rows;
__DATA__
$VAR1 = [
{
'locked' => 'no',
'stick' => 'foobar',
'last_update' => '2004-05-17 00:33:55',
'name' => 'post with curses',
'post' => 'some [censored] [censored] words',
'author' => 'values',
'last_updated_by' => 'jack',
'view' => 'other',
'id' => '2'
}
];
See the pod for
Regexp::Common for an explanation of
$RE{profanity} and other regular expressions it provides.