#! perl -slw use strict; my @good = qw[ aa1.2 aa1_bb2 ]; my @bad = qw[ aa1_2 aa1_2bb 1aa ]; my $re = qr[^[0-9]|^.*[_-][0-9]]; print $_, $_ !~ $re ? ' matches.' : ' doesnt match' for @good, @bad; __END__ C:\test>junk aa1.2 matches. aa1_bb2 matches. aa1_2 doesnt match aa1_2bb doesnt match 1aa doesnt match