in reply to Comparing sorted arrays
If all you need to know is that the two arrays are the same or not, you can use the fairly quick and dirty trick of stringifying them.
my @a1 = (...); my @a2 = (...); if ( @a1 == @a2 and do{local $"="\cA"; "@a1"} eq do{local $"="\cA"; "@ +a2"} ) { # They're the same }
The caveat is that you must choose a delimiter ("\cA" above) that does not appear in your data. Cntrl-A is a fairly safe bet for either text or numeric data, but if your data could include binary data, there is a small chance of a false positive. </code>
Examine what is said, not who speaks.
The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Comparing sorted arrays
by rir (Vicar) on Jan 16, 2003 at 20:43 UTC | |
by BrowserUk (Patriarch) on Jan 16, 2003 at 21:05 UTC | |
by rir (Vicar) on Jan 16, 2003 at 21:54 UTC |