noviceuser has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to compare two arrays which may have strings/elements separated by newline, spaces or comma, how can i ignore those special characters while comparing
e.g: suppose @array1 has contents like below
abc xyzand @array2 has contents like below
abc xyz
my $comp = Array::Compare->new; if ($comp->compare(\@array1, \@array2)) { print "array same\n"; } else { print "array not same\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: how to ignore spaces, commas or new line of an array when comparing
by hippo (Bishop) on Jun 16, 2021 at 08:33 UTC | |
by noviceuser (Acolyte) on Jun 16, 2021 at 08:44 UTC | |
by GrandFather (Saint) on Jun 16, 2021 at 08:59 UTC | |
by hippo (Bishop) on Jun 16, 2021 at 08:48 UTC | |
by noviceuser (Acolyte) on Jun 16, 2021 at 08:57 UTC | |
by hippo (Bishop) on Jun 16, 2021 at 09:07 UTC | |
| |
by dbuckhal (Chaplain) on Jun 16, 2021 at 14:36 UTC |
Back to
Seekers of Perl Wisdom