#!/usr/local/bin/perl use strict; use warnings; my $regexp = 'Perl Monks'; my $regexp2 = 'Perl Monks is a wonderful place to visit'; # even if Node Reaper is sometimes a bit loud if($regexp =~ m/^Perl Monks/gi) { print "\nFound.0."; } else { print "\nNot Found.0."; } if($regexp =~ m/^Perl Monks/gi) { print "\nFound.1."; } else { print "\nNot Found.1."; } if($regexp =~ m/^Perl Monks/i) { # No 'g' print "\nFound.2."; } else { print "\nNot Found.2."; } if($regexp2 =~ m/^Perl Monks/gi) { # 'g' is back, but different $var being tested print "\nFound.3."; } else { print "\nNot Found.3."; } if($regexp2 =~ m/^Perl Monks/gi) { # second identical use of $regex2 and match print "\nFound.4."; } else { print "\nNot Found.4."; }