my $string = "abcdefDaveghijkl"; if ( $string =~ /Dave/ ) { print "I found Dave.\n"; } #### my $string = "1.23.45"; print "Found a number.\n" if /\d+/; #### my $string = "1.234.567.txt"; print "Found a good filename.\n" if /\d+\.txt/; #### my $string = "1.234.567.txt"; print "Match.\n" if /567.txt/; #### /^\d+\.txt/ #### my $testname = " 456.txt"; my $filename; if ($filename = $testname=~ /^\s*?(\d+\.txt)\s*?$/ ) { print "Found a file named $filename.\n"; }