if( $type =~ /^CR\Z/i ) # or if( $type =~ /^CR$/i ) # if you want to allow for ignoring trailing newlines