This appears to work as requested, and it's a whole lot easier to read than some of the other options. :-)
#! /usr/bin/perl use strict ; use warnings ; my @words = qw( brian0 brian- -brian bri--an Bria-n br-i-an brian ) ; print map { "[$_]" } @words ; print "\n" ; my @good = grep { /^[[:alpha:]]/ # Starts with a letter && /[[:alpha:]]$/ # Ends with a letter && ! /--/ # No consecutive hyphens } @words ; print map { "[$_]" } @good ; print "\n" ;
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche
In reply to Re: Sorting words, keeping only words that start with a letter and contain only letter characters, and hypens, and end in a letter
by DamnDirtyApe
in thread Sorting words, keeping only certain words
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |