[Chicago-talk] regular expression help

Andy_Bach at wiwb.uscourts.gov Andy_Bach at wiwb.uscourts.gov
Wed Dec 30 10:52:40 PST 2009


Hey,

Not sure what your .msf file should look like but I mocked up a file like:
your message could not be delivered : andy at wiwb';

and get:
Apparent undelivered email your message could not be delivered FOUND in 
line 1 of Inbox.msf
  your message could not be delivered : andy at wiwb'; 
This line contains the next email address your message could not be 
delivered : andy at wiwb'; 

so *if* your .msf format is like that, then is should work.  You're doing 
a lot of extra work though - for one, if you know the name of the file, 
you don't need to do the  opendir/readir stuff (unless  you're planning to 
look for other files).  The:
             # look for the email address that comes after
              my $bad_email = '\@';
              if (/\b$bad_email\b/i) {

appears you've pared things down (you don't need the backslash inside 
single quotes) as /@/ should match anywhere /\b@\b/ would, I believe. This 
would normally be where you capture the info:
             # look for the email address that comes after
              my $bad_email = '@';
              if (/(\S+$bad_email\S+)/i) {

gets all the non-whitespace chars on either side of the '@' into $1.

a
----------------------
Andy Bach
Systems Mangler
Internet: andy_bach at wiwb.uscourts.gov
Voice: (608) 261-5738; 
Cell: (608) 658-1890

The bureaucracy is expanding to meet the needs of an expanding 
bureaucracy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20091230/a6c2e4ff/attachment.html>


More information about the Chicago-talk mailing list