in reply to consecutive spaces in piped open

I think BrowserUK is right. Try embedding quotes in the $filename string:
my $filename = q('This_filename_has_2 2_spaces.txt');
HTH, --traveler