in reply to Re^4: Pattern Matching problem
in thread Pattern Matching problem

I have tried to clean it up a bit but no guarantee as I cannot run it...

# what is in $test ? Not specified. my $string = quotemeta("$test"); foreach my $filename (@daten){ print "finding -$string- in $filename\n"."</br>"; open(my $file, "<", $filename) or die "Can't open the file: $!" +; while (<$file>) { if (/$string/) { print; # NEW STATEMENT my ($content) = m/(\/$string\/[a-z]*)/g; # different match +, might fail print $content; print "found string -$string- in line $. \n"; # $. is the +line number print "<br>"; } } }

UPDATE: added a print statement to check hypothesis

Replies are listed 'Best First'.
Re^6: Pattern Matching problem
by auhakim (Novice) on Jun 04, 2013 at 14:42 UTC

    the $test here recognized as a string, so the program will find the string that contain $test