use strict; use warnings; my $str = $ARGV[0]; if ($str =~ /^[a-zA-Z0-9]{6,20}$/) { print "success!\n"; } else { print "failure\n"; }