title: Using Template::Toolkit with array data from database
body: <p>I don't know why my script works when I declare arrays in my script, but doesn't work when I try to get array data from a database.</p>
  
  <h3>Perl</h3>
  
  <pre><code>use Template;
  
  my $template = Template-&gt;new;
  
  if ( $info ) {
  
      my $select = $DBH-&gt;prepare("SELECT FOO, BAR, MOO FROM tble WHERE CONCAT(FOO, ', ', BAR, ', ', MOO) LIKE ?");
      $select-&gt;execute('%' . $info . '%');
      $names = $select-&gt;fetchall_arrayref();
      foreach $names ( @$names ) {
          ( $variable1, $variable2, $variable3 ) = @$names;
      }
  }
  
  my $templ = &lt;&lt;START_HTML;
  &lt;!DOCTYPE html"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1
  +" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  [% FOREACH name IN list %]
      &lt;li&gt;
        &lt;div class='inforno'&gt;
          &lt;img src='inforno'&gt;
        &lt;/div&gt;
        &lt;div class='inforno'&gt;
          &lt;a href='#' class='inforno'&gt;[% name %]&lt;/a&gt;
        &lt;/div&gt;
        &lt;span class='inforno'&gt;
          &lt;a href='#' class='inforno'&gt;Edit user&lt;/a&gt;
        &lt;/span&gt;
      &lt;/li&gt;
      [% END %]
  
  &lt;/body&gt;
      &lt;/html&gt;
      START_HTML
  
  $template-&gt;process(\$templ, { list =&gt; \@$names })
          or die $template-&gt;error;
  </code></pre>
  
  <h3>output</h3>
  
  <pre><code>    ARRAY(0x2030674)
      ARRAY(0x2030634)
      ARRAY(0x2030618)
  </code></pre>
  
  <p>When I run I get that error. I want to get the array data from database.</p>