my $sep = chr(0); if (join($sep, @a) eq join($sep, @b)) { ... }