in reply to keeping spaces

None of read, sysread, readline (aka <>) and readpipe (aka qx``) collapse, trim or otherwise remove spaces. The problem is in code you haven't shown, assuming there were spaces in the first place.