#!/usr/bin/perl -w use strict; use CGI qw/ :standard *table /; use CGI::Pretty; # not necessary, but it makes for more legible html output my $db ="test.txt"; # moved header and start_html outside of loop # print takes a list, so you can join several items to print with commas print header, start_html( -title => 'Script' ), hr, start_table( { -width => '100%', -border => '0' } ); # It's more helpful to include $! in the error open( FILE, "<$db" ) or die "Well, whats up.. can't open file $!\n"; while ( ) { # no need to define $line here -- $_ is already defined, so you can use it # directly chomp; # Just a preference note. When working with arrays, I prefer to use # something a little easier to maintain, like: # my ( $name, $date, $something, $somethingelse ) = split/::/; # it's a bit easier than trying to remember the order of the fields in $db my @events = split/::/; print Tr( td( { -width => '22%' }, font( { -size => '+1', color => 'gray' }, b( "$events[0] $events[1], $events[2]" ) ) ), td( { -width => '78%' }, font( { -size => '+1', color => 'black' }, $events[3] ) ) ), Tr( td( { -colspan => '2'}, font( { -size => '2' }, $events[4] ) ) ); } print end_table, end_html; close FILE or die "Can't close $!\n";