Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: File NCopy concat

by hgolden (Pilgrim)
on Sep 14, 2006 at 22:43 UTC ( [id://573024]=note: print w/replies, xml ) Need Help??


in reply to Re: File NCopy concat
in thread File NCopy concat

He might be using File::Copy...

Replies are listed 'Best First'.
Re^3: File NCopy concat
by Anonymous Monk on Sep 14, 2006 at 22:57 UTC
    Yes, its actually File::NCopy.... the files needs to have space in them. So Im trying a find a way to do this keeping the spaces in.

      Try using File::Copy instead. File::NCopy seems to be broken.

      Update: the following illustrates the issue:

      use strict; use warnings; use File::Copy; use File::NCopy; use constant FILENAME_1 => 'File with spaces in the name.txt'; use constant FILENAME_2 => 'File with spaces in the name2.txt'; use constant FILENAME1 => 'Filename.txt'; use constant FILENAME2 => 'Filename2.txt'; open outFile, '>', FILENAME1; print outFile "Some text in non-spaced out file\n"; close outFile; open outFile, '>', FILENAME_1; print outFile "Some text in the spaced out file\n"; close outFile; File::NCopy::copy (FILENAME1, FILENAME2) or warn "Non-spaced to non-sp +aced failed with NCopy\n"; File::NCopy::copy (FILENAME_1, FILENAME2) or warn "Spaced to non-space +d failed with NCopy\n"; File::NCopy::copy (FILENAME1, FILENAME_2) or warn "Non-spaced to space +d failed with NCopy\n"; File::NCopy::copy (FILENAME_1, FILENAME_2) or warn "Spaced to spaced f +ailed with NCopy\n"; File::Copy::copy (FILENAME1, FILENAME2) or warn "Non-spaced to non-spa +ced failed with Copy\n"; File::Copy::copy (FILENAME_1, FILENAME2) or warn "Spaced to non-spaced + failed with Copy\n"; File::Copy::copy (FILENAME1, FILENAME_2) or warn "Non-spaced to spaced + failed with Copy\n"; File::Copy::copy (FILENAME_1, FILENAME_2) or warn "Spaced to spaced fa +iled with Copy\n";

      prints:

      Spaced to non-spaced failed with NCopy Spaced to spaced failed with NCopy

      DWIM is Perl's answer to Gödel
        File::NCopy's copy's argument is a glob pattern, not a file name. This pattern is passed to glob, which considers spaces to be pattern seperators, not literals. Refer to the passage I emphasised in the following snippet from File::Glob's documentation:

        Since v5.6.0, Perl's CORE::glob() is implemented in terms of [File::Glob's] bsd_glob(). Note that they don't share the same prototype — CORE::glob() only accepts a single argument. Due to historical reasons, CORE::glob() will also split its argument on whitespace, treating it as multiple patterns, whereas bsd_glob() considers them as one pattern.

        Update: File::NCopy works if you execute the following before calling copy:

        { package File::NCopy; use File::DosGlob qw( glob ); }

        And if the spaces are backslashed (or quoted).
        And if / is used as the path seperator on Windows.

        $filename = 'c:/directory\\ name/file\\ name.txt'; $filename = '"c:/directory name/file name.txt"'; $filename = 'c:/"directory name"/"file name.txt"';

        Truly, File::NCopy should be used with care if not considered outright broken. At the very least, it would be best if File::NCopy used bsd_glob rather than glob.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://573024]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2025-05-24 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.