in reply to Array lookup
I was trying to think outside the box and in the spirit of TIMTOWTDI
#!/usr/bin/perl -w use strict; my @FirstArray = qw(one two three); my @SecondArray = qw(four seven one eight two nine three seventeen); unless (index ((join "" , sort map {"@FirstArray" =~ /\b($_)\b/;} @Sec +ondArray) , (join "" , sort @FirstArray)) eq -1) { print "Second array contains all the elements in first array\n"; + } else { print "Second array does not contain all the elements in the first + array\n"; }
This is probably easily broken, but I thought it was neat.
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Array lookup
by CountZero (Bishop) on Apr 13, 2003 at 20:30 UTC | |
by Limbic~Region (Chancellor) on Apr 13, 2003 at 21:26 UTC | |
by CountZero (Bishop) on Apr 14, 2003 at 19:56 UTC | |
|
Re: Re: Array lookup
by CountZero (Bishop) on Apr 14, 2003 at 20:02 UTC |