Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Perl regex and word boundaries

by Kenosis (Priest)
on Feb 13, 2013 at 19:59 UTC ( #1018619=note: print w/ replies, xml ) Need Help??


in reply to Perl regex and word boundaries

Would the following be helpful?

use strict; use warnings; my $ha1 = "hostname62a"; my $ha2 = "hostname62b"; while (<DATA>) { print if /\s(?:$ha1|$ha2)\./; } __DATA__ 192.168.1.199 hostname62a.domain.com hostname62a 192.168.1.200 hostname62b.domain.com hostname62b 192.168.1.201 hostname62.domain.com hostname62 192.168.2.144 hostname62a-r.domain.com hostname62a-r 192.168.2.145 hostname62b-r.domain.com hostname62b-r

Output:

192.168.1.199 hostname62a.domain.com hostname62a 192.168.1.200 hostname62b.domain.com hostname62b


Comment on Re: Perl regex and word boundaries
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2015-07-04 21:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls