in reply to question on regexp:

I'll start with...

$all = ~s/[.|]+/|/g;

Have a look at perlop for details, but ~ is bitwise negation (so ~1 is 4_294_967_294). The s/// operator returns the number of replacements done, so that's what the ~ would be operating on. This is what happens:

  1. The s/// replacement is performed (on the contents of $_, see perlvar).
  2. The number of replacements that were done is bitwise negated.
  3. That's assigned to $all.

The $all =~ s/[.|]+/|/g; syntax is one I'm guessing you're familiar with. In that case, the substitution is done on the variable $all.

Update: Oops, I answered the wrong question.