#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use HTML::Template; use Tie::File; #use Data::Dumper qw(Dumper); my $q = new CGI; my $file = shift @ARGV; my $mark = shift @ARGV; my $file_raw = $file.".raw"; my $file_desc = $file.".desc"; #print $q->header(), Dumper(&process_files()); print $q->header(), &fill_template(&process_files()); exit; sub process_files { my @file_raw; my @result_set; tie @file_raw, 'Tie::File', $file_raw or die "Can't tie to file $file_raw: $!\n"; @result_set = map { my (undef, $host, $ip ) = split(" ", $_); my $highlight = ($host =~ /$mark/g) ? 'mark' : undef; { host => $host, ip => $ip, highlight => $highlight, }; } @file_raw; return \@result_set; } sub fill_template { my $recordset = shift; my $template = HTML::Template->new( filename => "report.tmpl", die_on_bad_params => 0, ); $template->param( title => 'Entwurf V2.0', recordset => $recordset, ); return $template->output; }