#!/usr/bin/perl $a = "Hello, this is a test."; # This looks for a match of "IS" inside string $a # the trailing i makes it case insensitive if ($a =~ m/IS/i ) { print "Found IS in string \$a\n"; print "Matched string : $&\n"; print "Text before match: $`\n"; print "Text after match : $'\n"; } else { print "Did not find IS in string\n"; } # Prints: # Found IS in string $a # Matched string : is # Text before match: Hello, th # Text after match : is a test.