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
In reply to Re: Regex: Searching for a string with special characters
by GrandFather
in thread Regex: Searching for a string with special characters
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |