Hi, When I download email from my log, so they are listed after each other like this. email@email.comemail1@email.comemail3@email.com Rather like this email@email.com email2@email.com email3@email.com Someone who can see which is missing a line break? #print "$line\n"; $mfh = $1; if ($mfh=~ m/email\./){ #$contents .= "$mfh\n" ; $seen{$mfh}=1; #print "$mfh\n"; }
If you are trying to see plain text that was contained in a file that you download, it could simply be that the editor that you're using to read the text requires a \r and possibly \r\n. If you are trying to see the text in a web browser, you'll probably have to use HTML code <br> instead of \n.
#print "$line<br>"; $mfh = $1; if ($mfh=~ m/email\./){ #$contents .= "$mfh<br>" ; $seen{$mfh}=1; #print "$mfh<br>"; } if its printing stright to your browser this will work.
Where is the actual print statement? The one in the post is commented with a hash, or am I missing something?
There is nothing else and it comes out with a list, but there is no line break between each email. Do you have suggestions for changes to the script?
Hi, There is little more here my $fh = new FileHandle ("< /var/log/mail.log") or die "an error occured "; my $line; while (<$fh>) { chomp; $line = $_; if ($line =~ m/^$dato .* to=<(.*\@email\.\w*).*status=sent.*>/){ #print "$line\n"; $mfh = $1; if ($mfh=~ m/email\./){ #$contents .= "$mfh\n" ; $seen{$mfh}=1; #print "$mfh\n"; }
How about this one: #!/usr/bin/perl -w use strict; my $date = 'Dec 24'; my $domain = 'email.com'; open(FH, '/var/log/mail.log') or die 'An error occurred.'; my %seen; while (<FH>) { m/^$date .* to=<([^>]+\@$domain)>.* status=sent .*/ and $seen{$1} = 1; } print join "\n", sort keys %seen; print "\n"; Code (markup):