#!/usr/bin/perl use warnings; use strict; $_ = 'This is a silly sentence. {3}. 2: but one may find it useful in learning regular expression.'; print "please enter your pattern: " my $pattern = ; chomp($pattern); if(/$pattern/) { print "I have found the pattern: "; print "\$1 is '$1'\n" if defined $1; } else { print "Sorry, we did not find anything this time.\n"; }