$ perl -e 'chomp($orig = ); ($tmp = $orig) =~ s/[^A-Z]//g; print "Copy: $tmp\nOriginal: $orig\n";' WeDfT Copy: WDT Original: WeDfT #### use strict; use warnings; chomp(my $input = ); (my $test = $input) =~ s/[^A-Z]//g; if ($test =~ /ABCD/) { print "'$input' matches!\n"; } else { print "'$input' does not match.\n"; } #### $ perl test.pl WaFFe 'WaFFe' does not match. $ [bwisti@w3d145 tmp]$ perl test.pl AeBwaffleCfrenchtoastD 'AeBwaffleCfrenchtoastD' matches!