Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: List::MoreUtils before, after and ... between?

by toolic (Chancellor)
on Feb 21, 2012 at 15:05 UTC ( #955331=note: print w/ replies, xml ) Need Help??

in reply to List::MoreUtils before, after and ... between?

Not very pretty, but it doesn't even go though your whole list once:

use warnings; use strict; use Data::Dumper; my @foo; my $flag = 0; for (qw<eval DBIC::3 DBIC::2 DBIC::1 MyApp::3 MyApp::2 MyApp::1 Dancer +::3 Dancer::2 Dancer::1>) { last if /Dancer/; $flag = 1 if /DBIC/; $flag = 2 if $flag and !/DBIC/; push @foo, $_ if $flag == 2; } print Dumper(\@foo); __END__ $VAR1 = [ 'MyApp::3', 'MyApp::2', 'MyApp::1' ];

Comment on Re: List::MoreUtils before, after and ... between?
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2015-03-27 22:16 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (620 votes), past polls