Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Regex: Searching for a string with special characters

by GrandFather (Saint)
on Nov 02, 2006 at 23:32 UTC ( [id://581982]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://581982]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-07-15 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.