in reply to Where to add substitution?

s/\t||\r||\n||\f//g is not a very good regex, because it only matches a tab (\t) or the empty string (corresponding to the empty string between two vertical bars in the regex).

You probably meant something like s/[\t\r\n\f]//g

Or, if you want to replace any consecutive list of whitespaces with a a single blank: s/\s+/ /g

See perlretut for a gentle introduction.

I would be very grateful if anyone could explain where I need to put the substitution

you need to apply it to the variables that holds that text from which you want to strip the whitespaces. Since you wrote that script (at least you didn't attribute it to anybody else) you should know which one it is.

(Update: fixed character class, johngg++)