Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
go ahead... be a heretic
 
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 contemplating the Monastery: (10)
As of 2014-04-18 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (465 votes), past polls