I would like to do something like push(@ary,\%hash) instead of @ary = (\%hash); so that
all the values will be in @ary.

I cannot get it to work. Any idears???

Soren

#!/usr/local/bin/perl -wT use strict; use HTML::Template; use CGI; use DBI; my $cgi = new CGI; use constant TMPL_FILE => "$ENV{DOCUMENT_ROOT}/um/templates/search.tmp +l"; my $tmpl = new HTML::Template( filename => TMPL_FILE ); my $search = $cgi->param("search"); my $rapport = $cgi->param("rapport"); my $dbh = DBI->connect("um","","","mysql") || die "Could not connect: $DBI::errstr\n"; my %attr = ( dbi_fetchall_arrayref_attr => {} ); my @selector; if ($rapport eq undef) { @selector = qw(fornavn efternavn cpr adresse zip city telefon mobil g_ +afsluttet bemyndigelse_til tjenestested id pic godkendelse_done); } else { @selector = qw(fornavn efternavn cpr bemyndigelse_til tjenestested god +kendelse_done g_afsluttet); } my @s = split(/ /, $search); my $row = $dbh->selectall_arrayref('select '. join(',' , @selector)." +from people where ((fornavn like '%$s[0]%') and (efternavn like '%$s[$#s]%')) or ( +fornavn LIKE '%$search%') or (efternavn LIKE '%$search%') or (cpr LIK +E '%$search%')",\ %attr); my %hash; my @ary = @$row; my ($i, $k, $v, $date); for ($i=0; $i<=$#ary; $i++) { %hash = %{$ary[$i]}; $date = con_date($hash{"g_afsluttet"}); $hash{"g_afsluttet"} = $date; }

HELP NEEDED HERE :o)
@ary = (\%hash);
HELP NEEDED HERE :o)
#--------Farven findes start ----------------- my $color; if ($hash{"godkendelse_done"} =~ '1') { $color = 'white'; } else { $color = 'red'; } #--------Farven findes slut ------------------ #----------Data slettes start ---------------- if ($rapport ne undef) { delete $hash{"g_afsluttet"}; } delete $hash{"godkendelse_done"}; #----------Data slettes slut ----------------- $tmpl->param( search => $search, rapport => $rapport , row => \@ary , +color => $color ); print "Content-type: text/html\n\n", $tmpl->output; $dbh->disconnect; sub con_date { my ($org_date) = @_; my ($yyyy, $mm, $dd) = ($org_date =~ /(\d+)-(\d+)-(\d+)/); my $ret = sprintf ("%02d-%02d-%04d", $dd, $mm, $yyyy); return $ret; }

In reply to push(@ary,\%hash) by Anonymous Monk

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.