You're not quite there with filehandles, yet. First you are telling Perl to get each line (actually record) in a file, one at a time, using while. Then you're making a reference to that same filehandle again while the line you want is already in the special variable $_.
Try this (untested) code:
print header, start_html('log parsing'); open(FILE, "<", 'log.txt') or die "Cannot open file: $!"; while (<FILE>) { # $_ 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<br>\n"; # add a newline for HTML output legibility } } close (FILE) or die "Cannot close file: $!";
--
Allolex
In reply to Re: Parsing a file
by allolex
in thread Parsing a file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |