#!/usr/bin/perl use strict; my $regex = 'foo'; my $test_string= 'bar'; print 'no match 1',"\n" if not $test_string =~ /$regex/; print 'no match 2 ',"\n" if ! $test_string =~ /$regex/; print 'no match 3', "\n" unless $test_string =~ /$regex/; #### no match 1 no match 3