# returns the largest element in a list sub max(@) { (sort @_)[-1] } # returns the union of two lists - i.e., all elements which are in at least one list sub union(@@) { ++$f{$_} foreach (@{$_[0]}, @{$_[1]}); keys %f } } # compares two list values for equality, by way of scalar(grep) # note that it takes into account the possibility of lists of different sizes sub lst_eq(@@) { scalar (grep { $_[0][$_] eq $_[1][$_] } (0..max ($#{$_[0]}, $#{$_[1]})) } # compares two hashes for equality, by way of scalar(grep) # note that it takes into account the possibility of hashes with different keys sub hsh_eq(%%) { scalar (grep { $_[0]{$_} eq $_[1]{$_} } union (keys (%{$_[0]}), keys (%{$_[0]}))) }