in reply to question on regexp:

$all = s/[.|]+/|/g; is short for $all = $_ =~ s/[.|]+/|/g;

For efficiency you may want to use $all =~ tr/.|/|/s; instead of $all =~ s/[.|]+/|/g;