while ( ) { if ( /^([A-Z]+)$/ ) { print "In if: $1\n"; } else { print "In else: $1\n"; } } __DATA__ FOO 1234 xyz BAR dfgdfg