Amit Nisim wrote:
>
> Hi All,
Hello,
> I want to compare between two arrays.
> How can I do it ?
>
> One way I know is :
>
> $a = (join " ",@a);
> $b = (join " ",@b);
> if ($b eq $a) { print "equal";}
Well you _can_ do this in one line. :-)
$ perl -le'@a = qw(one two three four); @b = qw(one two three four);
print "equal" if "@a" eq "@b"; '
equal
Of course this is assuming that the arrays are sorted in the same
order. If not you can do it this way.
$ perl -le'@a = qw(one two three four); @b = qw(two one four three);
print "equal" if "@{[sort @a]}" eq "@{[sort @b]}"; '
equal
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]