Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 musing on the Monastery: (13)
As of 2014-08-20 19:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (122 votes), past polls