Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 chilling in the Monastery: (5)
As of 2014-12-28 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls