in reply to Parse file for email address

The obvious thing is to look for the @ symbol. When you find it, extract the string thru it's word boundaries, then run the string thru Email::Validate..... and while there, look at Email::Address

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku

Replies are listed 'Best First'.
Re^2: Parse file for email address
by sri1230 (Novice) on Jan 22, 2010 at 14:26 UTC
    A portion of file is . I need to grab the first valid email address i find . In this case careers@....
    <div style="clear:both; border-top:1px solid #999; padding:1em + 0;"> <div class="rel100"> <div class="padRow"> <label class="leftlabel" style="font-size:1.15em; +width: 7em;">Description:</label> <div class="clear" style="clear:both;"></div> <div style="display:block; margin-left:8.65em;"> <div class="article" id="detailDescription" st +yle="margin-top:0;padding-top:0;">Job Description:<br>We are currentl +y seeking <b style="background:url(/assets/images/detail/default/high +lite.gif); font-weight: bold;">Java</b> Developers interested in lear +ning new technologies in the enterprise integration and content manag +ement arena.<br><br>Responsibilities:<br>Successful candidate will de +sign and develop software solutions that enable customers to develop +enterprise integration solutions that deliver content to business pro +cesses designed for net-centric operations. Other duties will includ +e participating as part of an agile development team within an enterp +rise SOA center of excellence for a major federal agency, participati +ng as part of agile scrum development team, working with system engin +eers to develop user stories and acceptance tests. Candidate will be + expected to elaborate details of acceptance tests, develop UML diagr +ams of fundamental design features, unit test code development, and d +evelop performance benchmarks for load testing.<br><br>Requirements: +<br>At least 2 years experience with relation database design, prefer +ably Oracle and SQL. Experience with installation and configuration +of web application servers: Tomcat, BEA Weblogic, and IBM Websphere r +equired. Preferred experience includes the following: <br>* Agil +e or Rational Unified Process (RUP)<br>* .NET and/or C++<br>* J +avascript and Browser clent development<br><br>Educational Requiremen +ts:<br>BS/MS in Computer Science or related field. (Experience can s +ubstitute for educational requirements.)<br><br>Flatirons Solutions p +rovides expert consulting and systems integration services to comme +rcial and government clients. For additional information, refer to w +ww.FlatironsSolutions.com<br><br>Flatirons Solutions is a successful +small business providing industry-leading solutions and outstanding c +ustomer satisfaction to our clients. In addition to interesting and +challenging work, we provide outstanding benefits including medical/d +ental/vision, Short-term & long-term Disability, 401(k) with employer + matching contributions, and much more.<br><br>Flatirons Solutions is + an Equal Opportunity Employer. <br>PLEASE RESPOND TO: careers@flatir +onssolutions.com</div> </div> <div class="clear" style="clear:both;">hr@flatiron +ssolutions.com</div> </div> </div> </div>
      When you download your file, the email address in question is hidden in html, so you first need to strip the html. I use lynx below, but there are Perl modules. Once you have the text, split into lines, just test each line.

      This dosn't account for emails that somehow get newlines in them, like thru bad cut and pasting, and the regex may leave something to be desired.

      The script below prints out 2 addresses in the array, select the first array element

      OUTPUT: careers@flatironssolutions hr@flatironssolutions
      #!/usr/bin/perl use warnings; use strict; my $html= $ARGV[0]; my $content = `lynx --dump $html`; #print "$content\n"; my @lines = split(/\n/,$content); #print "@lines\n"; my @addrs; while(<@lines>){ if( my ($num)= $_ =~ /(\b\w{1,}\Q@\E\w{1,}\b)/ ){ #print "$num \n"; push @addrs, $num; } } print "@addrs\n";

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku