try replace your while loop with the following:
while(<LOG>){
chop;
@line = split(/\|/);
next unless(substr($line[0], 0, 8) eq $selectedDate);
push(@display,{'displayDate'=>$line[0],
'pageViwed'=>$line[1],
'ip'=>$line[2],
'remoteAddy'=>$line[3],
'userAgeant'=>$line[4],
'referer'=>$line[5]});
}
the problem with your appoach is that when you push the \%rowData reference
to your @display, it always references the same underlaying %rowData hash.
that's probably not what you want. i can't actually test the above for you
right now but you might want to try it out and see how does it differ from
your original.
david
Renfield wrote:
> Hello,
>
> I am teaching myself perl. I have become stuck. My script is designed to
> write, read and display log files. I am having a hard time getting the
> correct data from the log file to a template file. My code will match the
> correct lines in the log file but when I pass it to the template it
> displays the first line matched each iteration of the HTML::Template loop.
> I am not sure if it is an error in the way I construct the data or an
> error in how I passing to the template.
>
> Here is the code
>
> [.. snip..]
>
> if ($view eq "detail") {
> open (LOG, $log_file) or die ("Couldn't open log file - $log_file -
> $!\n");
> while (<LOG>) {
> chomp;
> @line = split(/\|/, $_);
> $shortDate = substr($line[0], 0, 8);
> if($shortDate eq $selectedDate) {
> push (@displayDate, $line[0]);
> push (@pageViewed, $line[1]);
> push (@ip, $line[2]);
> push (@remoteAddy, $line[3]);
> push (@userAgeant, $line[4]);
> push (@referer, $line[5]);
> } else { next }
> $rowData{displayDate} = shift @displayDate;
> $rowData{pageViewed} = shift @pageViewed;
> $rowData{ip} = shift @ip;
> $rowData{remoteAddy} = shift @remoteAddy;
> $rowData{userAgeant} = shift @userAgeant;
> $rowData{referer} = shift @referer;
> push(@display, \%rowData);
>
> }
> close (LOG) or die ("Couldn't close log file - $log_file - $!\n");
>
> $template->param(DETAIL_DATA => \@display);
>
> [..snip..]
>
> Also, as I am very new to perl I would be grateful for any general tips.
>
> Thanks in advance!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]