hmb104 has asked for the wisdom of the Perl Monks concerning the following question:
How I can break out my foreach loop?
I'm checking if IP exists on a Cisco routing table, if it does then we can get more info. I want to say if the IP doesn't exist then break the loop with error. I have the following and it works great until I enter a non-valid IP which doesn't exist on my router:
foreach $match ( @Output ) { if ( $match =~ m/^Routing entry for / ) { @Data = split( ' ', $match ); $octet = $Data[ 3 ] ; last ; } } my @routing = split( /\./, $octet );
How I can add to say if m/^Routing entry for / didn't show up in all lines then die()? I have tried many ways and it never works
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: break out my foreach loop
by lidden (Curate) on Sep 02, 2012 at 06:39 UTC | |
by hmb104 (Sexton) on Sep 02, 2012 at 06:52 UTC | |
by james2vegas (Chaplain) on Sep 02, 2012 at 06:54 UTC | |
by hmb104 (Sexton) on Sep 02, 2012 at 06:59 UTC | |
|
Re: break out my foreach loop
by NetWallah (Canon) on Sep 03, 2012 at 00:12 UTC | |
|
Re: break out my foreach loop
by philiprbrenan (Monk) on Sep 02, 2012 at 12:10 UTC |