Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by LanX (Canon)
on Feb 21, 2012 at 16:15 UTC ( #955343=note: print w/ replies, xml ) Need Help??


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

Not sure if I understand your problem completely, why not simply combining grep and flip-flop?

This should be close:

DB<134> @list= ("a".."c","DBIC","A".."C","DANCER","a".."c") => ("a", "b", "c", "DBIC", "A", "B", "C", "DANCER", "a", "b", "c") DB<135> grep { /DBIC/.. /DANCER/ } @list => ("DBIC", "A", "B", "C", "DANCER")

Cheers Rolf


Comment on Re: List::MoreUtils before, after and ... between?
Download Code
Re^2: List::MoreUtils before, after and ... between?
by ikegami (Pope) on Feb 21, 2012 at 23:20 UTC
    That's not the requested output.
      ...This should be close..

      UPDATE:

      Still not sure what the requested output is, but if it's only about eliminating the edges try

      DB<101> @list= ("a".."c","DBIC","A".."C","DANCER","a".."c") => ("a", "b", "c", "DBIC", "A", "B", "C", "DANCER", "a", "b", "c") DB<102> grep { /DBIC/ .. /DANCER/ and ! /DBIC/ and ! /DANCER/ } @lis +t => ("A", "B", "C")

      not DRY but effective.

        The code is not even close to what it should be, and it's totally irrelevant if it's simply the output that is close to what it should be.

        That looks very readable and produces the output I said I need, but not for some of the edge cases that other monks thought of:
        say for grep { /DBIC/ .. /Dancer/ and !/DBIC/ and !/Dancer/ } qw<eval +DBIC::3 eval DBIC::2 DBIC::1 MyApp::3 MyApp::2 MyApp::1 Dancer::3 Dan +cer::2 Dancer::1>;
        and
        say for grep { /DBIC/ .. /Dancer/ and !/DBIC/ and !/Dancer/ } qw<MyApp +::3 MyApp::2 MyApp::1 Dancer::3 Dancer::2 Dancer::1>;
        I hadn't thought of these edge cases when I posted, but the first one is a distinct possibility. The example code with reverse before works ok for these.

        Thanks for showing me a new way of using the flip-flop.



        - Boldra

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-08-29 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (277 votes), past polls