Extract IP Address from Entourage message header

In Entourage, I want to extract individual IP addresses from the headers of messages in my deleted items folder, collect them into a list, and put the list on the clipboard. Header lines from which to extract the IP address are either or both of the following:
X-YahooFilteredBulk: 222.82.131.22
X-Originating-IP: [222.82.131.22]

The following code appears promising as a starting point. It uses grep, perl, sort and uniq to return a list of unique sorted URLs from a body of text. I can handle the grep pattern for an IP address.

Sorry I don’t have more code written as a starting point. I thought I’d ping the group first.

Steve

– When parsing HTML source, I find it easier to use a PERL GREP shell script and also sort and remove duplicates using sort and uniq respectively
– SOURCE: http://bbs.applescript.net/viewtopic.php?id=13354

set myText to “<a href="http://zombo.com">http://zombo.com This is a bunch of ugly text with URLs littered in it
<a href="http://bbs.applescript.net/viewtopic.php?id=13333\”>http://bbs.applescript.net/viewtopic.php?id=13333 yadda yadda
yadda <a href="http://www.macscripter.net/\“>http://www.macscripter.net/ yadda yadda yadda <a href="mailto:John@doe.com">mailto:John@doe.com yadda yadda
yadda yadda <a href="http://www.yahoo.com">http://www.yahoo.com yadda yadda
yadda yadda <a href="http://apple.com/applescript\”>http://apple.com/applescript
<a href="ftp://ftp.gimp.org/\“>ftp://ftp.gimp.org/
<a href="aim:JohnDoe">aim:JohnDoe”

try
open location ((choose from list extract_URLs(myText)) as string)
end try

on extract_URLs(the_string)
try
return (do shell script “echo " & quoted form of (my snr(the_string, “>”, “>” & (ASCII character 10))) & " | grep ‘href’ | perl -ne ‘m/.href="?([^>"]+)"?./; print $1,"\n";’ | sort -f | uniq”)'s paragraphs
on error the_error number the_number
log the_error & " (" & the_number & “)”
return {}
end try
end extract_URLs

on snr(the_string, search_string, replace_string)
tell (a reference to my text item delimiters)
set {old_tid, contents} to {contents, search_string}
set {the_string, contents} to {the_string’s text items, replace_string}
set {the_string, contents} to {the_string as Unicode text, old_tid}
end tell
return the_string
end snr