On Nov 22, Pinar 2 said:

>> >syntax error at ./shopdiff.pl line 5, near "++ for "
>> >Execution of ./shopdiff.pl aborted due to compilation errors.
>>
>> You're using an older version of Perl.  Do:

If you're using 5.005_03, then the postfix-for should work.  Perhaps your
PROGRAM is using an older version of Perl that you still have hanging
around somewhere?

>Thanks that worked. It didn't give me differences though, it gave me the
>common list items. Perhaps the unique to sub will give the differences but
>I can't get that one working either.

If you have arrays with UNIQUE elements, then the following code returns
the elements in one but not both:

  sub diff {
    my %seen;
    for (@_) {
      for (@$_) {
        $seen{$_}++
      }
    }
    return grep $seen{$_} == 1, keys %seen
  }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to