in reply to Sorting words, keeping only certain words

use strict; sub do_it_for_anonymous_monk { my @words = @_; my $word; my @results; foreach $word (@words) { if (($word =~ m/^[a-z|A-Z].*[a-z|A-Z]$/) && ($word !~ /--/)) { push @result, $word; } } return @results; } my @words = ("br-ian", "bri--an", "br-i-an", "brian", "brian0", "brian +o", "2sdha"); do_it_for_anonymous_monk(@words);
  • Comment on Re: Sorting words, keeping only words that start with a letter and contain only letter characters, and hypens, and end in a letter
  • Download Code