Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Matching a Word Exactly

by karlgoethebier (Abbot)
on Oct 09, 2014 at 11:30 UTC ( [id://1103286]=note: print w/replies, xml ) Need Help??


in reply to Matching a Word Exactly

BTW, proper indention and omitting unnecessary whitespace isn't a bad thing :-)

use strict; use warnings; while (<DATA>) { if ( $_ =~ m/\bGuinea\b/ ) { print "We have a match\n"; # m/\bGuinea\b$/ matches Guinea at end # m/^\bGuinea\b$/ matches Guinea at the beginning } else { print "We do not have a match\n"; } } __DATA__ Papua New Guinea I live in Guinea Guinea Bissau Equatorial Guinea

See also Perltidy.

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1103286]
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-04-20 02:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found