Go and read
Death to Dot Star! >;->
The problem is that your regex, while not greedy, still matches as
early as possible, causing it to match things like '
stuff</td><td>email@email.com'.
If you replace the dots with a negated character classes, preventing them from matching the angle brackets of the
<td> tags, then it should work perfectly:
#!/usr/bin/perl -w
use strict;
my $data = 'any number of td/tds><td>stuff</td><td>email@email.com</td
+><td>more stfff</td><td>next@next.co.uk</td><td\>r.h@a.com</td>';
my @emails = ($data =~ /<td>([^>\@]+?\@[^<\@]+)<\/td>/g);
print join "\n", @emails;
However, this is definitely a job for
Email::Find:
#!/usr/bin/perl -w
use strict;
use Email::Find;
my $data = 'any number of td/tds><td>stuff</td><td>email@email.com</td
+><td>more stfff</td><td>next@next.co.uk</td><td\>r.h@a.com</td>';
find_emails($data, sub {
my($email, $orig_email) = @_;
print $email->format."\n";
return $orig_email;
});