in reply to Checking on multiple email addresses in a string

Email::Valid is probably the best solution for both checking for illegal characters and multiple emails addresses. This module appears to find an address invalid if you try to put multiple addresses there. Alternately you could use Mail::Address and just make sure you get one address out of its parse method. Your regex will not handle many addresses which it is valid to send e-mail to, such as "me, you@example" <me@example.com> or (from alias someaddr@somewhere) me @ example . com or me@[1.2.3.4] or space(@)@example.com (and worse!). Also your idea of looking for more then one @ will certainly not work on addresses like that, either. Nor will checking for comma and/or space.

That said, character classes are always inclosed by []s. (\w\.\-)+ tries to match a word character followed by a dot followed by a - one or more times. You can fix this problem by using a real character class: [\w.-]+ (note that in character classes the . is not special, and the - is not special at the end or beginning of the character class.)

You can check for more then one @ with tr: my $count = $addy =~ tr/@//; if ($count > 1) { ... } You could also try a regex like /@[^@]*@/ to check for that.

update: tr/+/*/ in last regex.

update: fixed first sentence (to mention multiple e-mails.)