This should be a valid invocation, but executeComm will receive the command cat file name.txt, and consequently, will fail. The same would happen if $ perl test.pl 'file name.txt' is passed, and perl test.pl 'file\ name.txt' would succeed, but the file tests on isReadableFile fail

This site has a pretty good discussion of these sorts of problems, and helped me in a similar situation.

In particular this fix worked well for me and seemed fine when moving between Unix and windows (i didn't try anything else)...

"Spaces could be transparently handled (no pun intended) with U+00A0, a non-breaking space, which in fact it is. Really. If the system is presented with a filename containing U+0020, it just replaces it unilaterally with U+00A0."

Hope this helps

UPDATE:

This clearly isn't how i got round the problem too, as it doesn't get around the original problem (see example below)... Thanks JavaFan

Multiple-arg system() doesn't quite work like that (read this). Redirection using the shell metacharacter ">" is handled by the shell, which reads the entire string "program $ref_file > $outfile", parses it, and executes the command with redirection.

When you do multiple-arg system, you're going raw and skipping the shell (usually). Redirections have to be performed manually and you'll lose some convenience you get with using a shell. Example: