in reply to Regex: Searching for a string with special characters
you may also want to remove line ends (chomp).
Update: note that your sample would be better given as follows to avoid external files:
use warnings; use strict; my $search = "Bus(Mini)\n"; while (<DATA>) { if ( ! /$search/ ) { print "No Match found\n"; next; } else { print "Found $search in main file\n"; } } __DATA__ TestFile: Bus Bus(Mini) Car Van
DWIM is Perl's answer to Gödel
|
---|
In Section
Seekers of Perl Wisdom