2009/11/2 Brent Clark <brentgclarkl...@gmail.com>:
> Hiya
>
> 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.

This is probably not the most elegant solution but you could capture
everything after 'Interface\s+:\s+(.*)' and the split it on the
white-space.

(my $h2ip) = ($str =~ m/Interfaces\s+:\s+(.*)/);
my @h2ip = split(/\s+/, $h2ip);

HTH,
Dp.

-- 
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