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

Answer: How to Test if Two Arrays are Ordered in the Same Way

( #465085=categorized answer: print w/ replies, xml ) Need Help??

Q&A > arrays > How to Test if Two Arrays are Ordered in the Same Way contributed by monkfan

Ok, this is one the answer given by most revered tlm to me the other day:
sub test_ordered { my ( $ref, $test ) = @_; # $i scans the indices of @$ref; # $matched keeps count of # of elements matched in @$test; my ( $i, $matched ) = ( 0, 0 ); OUTER: for ( @$test ) { while ( $i < @$ref or return 0 ) { if ( $ref->[ $i++ ] eq $_ ) { last OUTER if ++$matched == @$test; last; } } } return 1; }
More can be found here. Don't vote my root posting but vote those remarkable answers you will find there.

Comment on Answer: How to Test if Two Arrays are Ordered in the Same Way
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

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

    How do you remember the number of days in each month?











    Results (99 votes), past polls