As a side comment, you might want to account for Irish names that have an apostrophe in them. Also, you might be matching some things that are not names.
use Test::More; my $holli = qr/^\w[\w\s\-]+$/; my $kyle = qr{ \A \w [\w\s'-]+ \z }xms; my @good_names = ( 'Smith', q{O'Donnelly}, 'Smith-Jones' ); my @bad_names = ( '12', "\\Windows\\System", '' ); plan 'tests' => (2 * scalar @good_names) + (2 * scalar @bad_names); foreach my $name ( @good_names ) { ok( $name =~ $holli, "holli pattern matches [$name]" ); ok( $name =~ $kyle, "kyle pattern matches [$name]" ); } foreach my $name ( @bad_names ) { ok( $name !~ $holli, "holli pattern does not match [$name]" ); ok( $name !~ $kyle, "kyle pattern does not match [$name]" ); } __END__ 1..12 ok 1 - holli pattern matches [Smith] ok 2 - kyle pattern matches [Smith] not ok 3 - holli pattern matches [O'Donnelly] # Failed test 'holli pattern matches [O'Donnelly]' # in perlmonks.pl at line 18. ok 4 - kyle pattern matches [O'Donnelly] ok 5 - holli pattern matches [Smith-Jones] ok 6 - kyle pattern matches [Smith-Jones] not ok 7 - holli pattern does not match [12] # Failed test 'holli pattern does not match [12]' # in perlmonks.pl at line 22. not ok 8 - kyle pattern does not match [12] # Failed test 'kyle pattern does not match [12]' # in perlmonks.pl at line 23. ok 9 - holli pattern does not match [\Windows\System] ok 10 - kyle pattern does not match [\Windows\System] ok 11 - holli pattern does not match [] ok 12 - kyle pattern does not match [] # Looks like you failed 3 tests of 12.
(OK, maybe Test::More was overkill to make my point.)
In reply to Re: WebApps and Encoding
by kyle
in thread WebApps and Encoding
by holli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |