in reply to Sorting words, keeping only certain words
The grep expression tests two separate regex matches: (1) must begin and end with a letter, (2) must not have two or more consecutive hyphens.@sorted = sort grep { /^[a-z].*[a-z]$/i and not /-{2,}/ } @orig
update: In case you want a case-folded sort (so that "amen" can be placed between "Amen" and "Amenable") add this block between the "sort" and "grep" above (this is copied from "perldoc -f sort"):
{uc($a) cmp uc($b)}
|
|---|