#!/usr/bin/perl -w use strict; my $re = qr/hello/; my $string1 = "hello"; my $string2 = "good bye"; if($string1 =~ $re){ print "Match $string1\n"; } if($string2 =~ $re){ print "Match $string2\n"; }