Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Regex and splitting

by Kenosis (Priest)
on Apr 29, 2012 at 05:45 UTC ( #967900=note: print w/ replies, xml ) Need Help??


in reply to Regex and splitting

Although this solution doesn't use split, you can capture the ip between the colon and comma with just a regex--given your file's contents:

use strict; use warnings; use 5.010; say /:(.*),/ while <DATA>; __DATA__ host1 dns:192.168.243.30,asdf host2 dns:192.168.243.1,qwert

I know this doesn't specifically address your "Is there something missing with my code?" question, as the prior comments effectively have, but it may be interesting information to you.

Hope this helps!


Comment on Re: Regex and splitting
Select or Download Code
Replies are listed 'Best First'.
Re^2: Regex and splitting
by Anonymous Monk on Apr 30, 2012 at 04:22 UTC

    Actually the one GodFather helped me by removing the $ sign and just split it if in case i want to display only the ip address. Thanks for the help really appreciate :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2015-08-31 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (354 votes), past polls