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.

--sacked

In reply to Re: Modifying data in a hash before sending to template by sacked
in thread Modifying data in a hash before sending to template by Steny

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.