use warnings; use strict; use Test::More qw(no_plan); my $emailsregex = qr/\w+@\w+\.(net|com|org)/; while () { like($_, $emailsregex) } __DATA__ timmytimmers@aol.com hillary-hillers@aol.com garbygerbil@herbill.gerbil.org garbygerbil@herbill.gorgil.org reginald_reggers@aol.com #### ok 1 ok 2 not ok 3 # Failed test (emailsregex.pl at line 8) # 'garbygerbil@herbill.gerbil.org # ' # doesn't match '(?-xism:\w+@\w+\.(net|com|org))' not ok 4 # Failed test (emailsregex.pl at line 8) # 'garbygerbil@herbill.gorgil.org # ' # doesn't match '(?-xism:\w+@\w+\.(net|com|org))' ok 5 1..5 # Looks like you failed 2 tests of 5.