use strict; use warnings; print "Enter a string: "; chomp ($_ = <>); my $msg = !/a/i ? 'String did not match' : !/a.*b/i ? 'The string has an a, but not a following b' : 'The string has an a, but also a following b' ; print $msg, "\n"; #### my $msg = /a.*b/i ? 'The string has an a, and also a following b' : /a[^bB]*$/i ? 'The string has an a, but not a following b' : 'String did not match' ;