Thanks, Matt. I'll experiment with this.

***********************************************************
On Jan 27, 2011, at 3:31 PM , Matt Martini wrote:

Doug,

First you save the program to a file, let's say extract_email_addresses.pl

Then you can use this perl program two ways:

1) If you are comfortable with the command line (via Terminal.app)
   you can utilize it this way:

   $ cat file_of_data | perl extract_email_addresses.pl > file_of_email_addr.txt
   
   This will create the file_of_email_addr.txt output document

2) To stay within BBEdit you can put the file in 
   
   "~/Library/Application Support/BBEdit/Unix Support/Unix Filters/"
   
   Then just open the file_of_data and use the drop down menu item:
   
   #! --> Unix Filters --> extract_email_addresses.pl
   
The second method is probably the way to go if you need to show this to a 
colleague.   

For anyone who is interested I've provided a commented version of the script 
below.


#!/usr/bin/perl

$tldn = '(com|net|edu|gov|int|mil|org|biz|name|coop|aero|info|[a-z][a-z])';  
#most valid top level domains

while ( chomp( $line = <> ) ) {                                 # read in each 
line of the file
    while (
        $line =~ m{                                             # match email 
addr.
                        <                                       # opening 
delimiter
                        (                                       # capturing 
paren
                            \w[-.\w]*                           # username
                            \@                                  # @
                            [-a-z0-9]+(\.[-a-z0-9]+)*\.$tldn    # domain name
                        )                                       # closing paren
                        >                                       # closing 
delimiter
                    }gx                                         # match all 
occurances on the line
          )
    {
        print $1 . "\n";                                        # print found 
email addr.
    }
}


And for those who enjoy the terseness :p here is the line noise version:

while(chomp(<>)){while(m{<(\w[-.\w]*\@[-a-z0-9]+(\.[-a-z0-9]+)*\.$tldn)>}g){print
 $1 . "\n";}}

Enjoy

Matt

On Jan 27, 2011, at 2:28 PM, Doug Pinkerton wrote:

I know nothing about Perl. Is this nicely terse?  : )



-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to