in reply to Seeing double
Always use -w and use strict. my $textfile = "iwn.txt"; Use my to declare variables under use strict.#!/usr/bin/perl -w use strict;
You were using C style looping. Perl loops are much nicer.open TEXT, $textfile or die "Can't Open $textfile"; my ($email, $id); while (<TEXT>){ $email ||= $_ if /Email address:/; $id ||= $_ if /Message-Id:/; }
Pulling these variables out of the loop ensures they only get printed once.close TEXT; print $email; print $id;
|
---|