in reply to dos2unix problem

try:
s/\r//g;
The "g" modifier makes sure all instances get changed and not just the first.

cLive ;-)