Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: break out my foreach loop

by philiprbrenan (Monk)
on Sep 02, 2012 at 12:10 UTC ( #991271=note: print w/ replies, xml ) Need Help??


in reply to break out my foreach loop

Or make it a sub so you can return an empty list if not found:

use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); sub match($) { my ($Output) = @_; for my $match ( @$Output ) { if ( $match =~ m/^Routing entry for / ) { my @Data = split( ' ', $match ); my $octet = $Data[ 3 ] ; return split( /\./, $octet ) } } () } say "@{[match([split /\n/, <<'END'])]}"; a b c Routing entry for 1.2.3.4 END

Produces

1 2 3 4


Comment on Re: break out my foreach loop
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2015-07-04 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls