in reply to RE: RE: Comparing Arrays
in thread Comparing Arrays

Either way it'll still contain a very similar error. If you pick a "separator" you must guarantee that it won't appear in any of the list element in order to prevent this error. This "string" method can still be shown to perform improperly with certain arrays:
my @a1=('3 5 7'); my @a2=('3','5','7');

Replies are listed 'Best First'.
RE: RE: RE: RE: Comparing Arrays
by jlistf (Monk) on Sep 01, 2000 at 23:09 UTC
    you can avoid this error by performing the test twice, changing the separator between the two tests. i believe (until someone can show me a counter example) that it is impossible to construct two different arrays that will pass this test twice with different separators. ( <--- was that really english? wow was that poorly written. )

    jeff

    Update: this post was mostly to show how to avoid the error in the stringifying subroutine, but i also did some benchmarking. and... here's what i've found. testing with two separators takes about the same amount of time as looping if the arrays are identical. i don't really know about memory requirements though.
      By that time, you've thrown around so much temporary string space and stringification stuff that you might as well have done the loop.

      -- Randal L. Schwartz, Perl hacker