Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-20 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found