Mega Code Archive

 
Categories / Perl / Regular Expression
 

Pattern Tester

#!/usr/bin/perl use warnings; use strict; $_ = q("'yes' or 'no',".); print "Enter some text to find: "; my $pattern = "test"; chomp($pattern); if (/$pattern/) {     print "The text matches the pattern '$pattern'.\n"; } else {     print "'$pattern' was not found.\n"; }