in reply to List Compare

The pitfall that is hard to avoid when using the join-to-form-a-regexp solution is that, for example:
@b = (ab, c);
is probably not construable (depending on your exact view of the requirement) as being an ordered subset of:
@a = (a, bc, d);
My first reaction was therefore to use the standard join( $;, array ) approach ($; is a non-printable field separator often used for this purpose), while mulling over the possibility that the data might be binary and so accidentally contain a byte equal to $; (it's the ascii of decimal 19 and reassigning $; would just move the problem to a different false-positive), the following non-regexp approach drifted into my head - it does at least do about the minnimum necessary while being safe from the above join-delimitation problem:
sub isOrderedSublist{ my ( $aref, $bref ) = @_; # references to arrays my @a = @$aref; # major - copy so we can safely destroy my @b = @$bref; # minor my $firstMatched = 0; while( not Empty( \@a ) ) { if ( $a[0] eq $b[0] ) { $firstMatched = 1; shift @b; else { $firstMatched and last; } shift @a; } return Empty( \@b ); # success if failure eliminated } sub Empty{ my $aref = shift; return( not ( $#$aref + 1 ) ); }
update: factorised to reduce a couple of lines

-M

Free your mind