Created
June 29, 2010 14:29
-
-
Save waffle2k/457274 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# Parse some file or text, looking for what would appear to be a valid | |
# RFC-821 style email header. Attempt to pull out the DKIM-Signature | |
# portion of that file and print it. | |
# | |
# Author: pete (at) killallhumans (dot) ca | |
use strict; | |
my $text = do { local $/; <>; }; | |
$text =~ s/\r//g; | |
my $dkim = undef; | |
if ( $text =~ /(DKIM-Signature:.*?)(?=^\s*$)/gsm ){ | |
$dkim = $1; | |
} | |
elsif ( $text =~ /(DKIM-Signature:.*?)(?=^\S)/gsm ){ | |
$dkim = $1; | |
} | |
else { | |
$dkim = $1 if ( $text =~ /(DKIM-Signature:.*)/gsm ); | |
} | |
die( "Could not parse DKIM-Signature\n" ) | |
unless $dkim; | |
print $dkim; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment