in reply to match function

It is easier to test explicitly for what you want.
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";

UPDATE: Even better, use positive tests:

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' ;
Bill