John W. Krahn wrote:
Brent Clark wrote:

I was hoping that someone would be kind to help me.

I have a string like so :

Haresources : 10.203.4.5, Interfaces : 10.203.4.5 10.203.4.7

Im trying to get the ip's after Interfaces into an array, but for the likes of me, im just not getting it right. This is what I currently got.

my @h2ip = ($tmp{ $opt_H2 } =~ /(?:Interfaces\s:\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))/gi );

If someone could help, I would be most appreciative.

my @h2ip = $tmp{ $opt_H2 } =~ /Interfaces\s*:/ig && $tmp{ $opt_H2 } =~ /(?<=\D)\d{1,3}(?:\.\d{1,3}){3}(?=\D|$)/g;

That would definitely be better as:

my @h2ip = $tmp{ $opt_H2 } =~ /Interfaces\s*:/ig ? $tmp{ $opt_H2 } =~ /(?<=\D)\d{1,3}(?:\.\d{1,3}){3}(?=\D|$)/g : ();



John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to