in reply to Broken regexp

I guess you are using | as a separator. The problem with your approach is that you want to replace the content, but you are matching the separators as well - but separators are "shared". One way of solving this is the use of split and join:
join "|" => map {length () ? $_ : '\N'} split /[|]/ => $line, -1;
But that assumes there are no leading or trailing vertical bars. Or you can use lookahead:
$line =~ s'[|](?=[|])'|\N'g;

Abigail