#!/usr/bin/perl my $string = $ARGV[0]; if($string =~ m#(\Aof|of\z)#){ print "matched out at start or end\n"; }