print header, start_html('log parsing'); open(FILE, "<", 'log.txt') or die "Cannot open file: $!"; while () { # $_ is your message, but you could also # say "while my $message ..." to store # each line in $message chomp; # gets rid of newlines, etc. if ( m/(^Alberta226:)\s+(.*)/ ) { # you just need # the one anchor print "$1: $2
\n"; # add a newline for HTML output legibility } } close (FILE) or die "Cannot close file: $!";