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

#!/usr/bin/perl use strict; use warnings; use encoding 'utf8'; my $dir = "/tmp/Foo"; unless (-e $dir){ mkdir $dir or die; } chdir $dir or die; opendir my $dh, $dir or die; my @files = readdir $dh; closedir $dh; print "Got ", scalar @files, " files\n"; foreach my $char ("\x{20}", "\x{A0}") { my $file = "foo{$char}bar"; open my $fh, ">", $file or die; } opendir $dh, $dir or die; @files = readdir $dh; closedir $dh; print "Got ", scalar @files, " files\n"; open my $fh, ">", 'foo baz' || die "Failed to open file : $!"; close $fh || die "Failed to close file : $!"; foreach my $char ("\x{20}", "\x{A0}") { my $file = "foo".$char."baz"; if (-e $file){ print "got it\n" } else { print "not got it...\n"; } } system("cat foo\x{20}baz"); system("cat foo\x{A0}baz");

Just a something something...

In reply to Re^2: Passing commands to subroutines by BioLion
in thread Passing commands to subroutines by citromatik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.