if (-e $logfile) { my $fh=new IO::File($logfile,'r'); @lines=$fh->getlines(); $fh->close; } my $log=[]; foreach my $l (@lines) { if ($l=~m/error/i) { push @$log,{logLine=>$l,error=>1}; } else { push @$log,{logLine=>$l}; } } $tmpl->param(log1=>$log); template snippet: