in reply to Re: replace text using hash
in thread replace text using hash

> modify the regex to treat whitespace agnostically, and then replicate the type of whitespace in your result.

OK I missed that part. But I think substituting each blank with a grouped (\s) should do.

Like this the positions of each whitespace match is known and can be mapped back to blank before doing the hash look-up.

Evidently using any whitespace different to blank must be forbidden in the keys.

And at this point it gets obvious that looking at CPAN for a ready to use module should be a good idea! :)

update

In hindsight thats BS. This kind of translation with different length expressions can't reproduce good formatting.

It's better to hold each paragraph in one line in a normalized form, where each non-blank whitespace is eliminated and to do the formatting again after substitution .

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)