Commit Diff


commit - 895156fd3e4fba0170813ea3a2d168af1505a5b1
commit + 8400f38c8ccbac841e8d563a1449a93c7aadc984
blob - 08f658b130d1ed0a7a22e33c3c7555cabe05f38c
blob + 74e58b8246fcbac81526b3ddb0392348f0e5d5a0
--- mailread.pl
+++ mailread.pl
@@ -6,26 +6,19 @@ use IPC::Run3;
 my $content = do { local $/; <> };
 my ($headers, $body) = split(/\n\n/, $content, 2);
 my $ishtml = qr/< *(html|head|body|div|table|p|span|br) *\/?>/i;
-my @links;
 
 run3(['lynx', '-dump', '-force_html', '-stdin'], \$body, \$body, undef) if ($body =~ $ishtml);
+open(my $fh, '>', "$ENV{HOME}/.maillinks");
+my $i = 0;
 $body =~ s{(https?://[^\s<>"]+)}{
 	if (length($1) > 80) {
-		"[Link #" . (push @links, $1) . "]";
+		print $fh "$1\n";
+		"[Link #" . ++$i . "]";
 	} else {
 		$1;
 	}
 }gex;
+close $fh;
 
-if (@links)
-{
-	open(my $fh, '>', "$ENV{HOME}/.maillinks");
-	foreach my $link (@links)
-	{
-		print $fh "$link\n"
-	}
-	close $fh;
-}
-
 print "$headers\n\n$body";