in reply to Copy dir with space

The Below code does not work.

Yes, it doesn't compile for me either :) This does compile

#!/usr/bin/perl -- use strict; use warnings; use Path::Tiny qw/ path cwd /; my @files = grep { -f $_ } path( '/pr/perl_by_example/' )->children(); for my $source ( @files ) { my $destination = path( "/pr/book/", $source->basename ); $source->copy( $destination ); }

Replies are listed 'Best First'.
Re^2: Copy dir with space (Path::Tiny)
by adriang (Sexton) on Jul 10, 2014 at 10:41 UTC

    Thanks for the quick replay, Unfortunately the dest dir is empty and I don't get any error when I run the script.

      well, then you got no files

        Sure I have:

        [root@adimac pr]# ls -l /pr/perl_by_example/ total 0 drwxr-xr-x 9 gherasima _unknown 306 Oct 8 2007 Chapter 03 drwxr-xr-x 24 gherasima _unknown 816 Oct 8 2007 Chapter 04 drwxr-xr-x 69 gherasima _unknown 2346 Oct 8 2007 Chapter 05 drwxr-xr-x 28 gherasima _unknown 952 Oct 8 2007 Chapter 06 drwxr-xr-x 28 gherasima _unknown 952 Oct 10 2007 Chapter 07 drwxr-xr-x 42 gherasima _unknown 1428 Oct 10 2007 Chapter 08 drwxr-xr-x 56 gherasima _unknown 1904 Oct 10 2007 Chapter 09 drwxr-xr-x 50 gherasima _unknown 1700 Oct 12 2007 Chapter 10 drwxr-xr-x 32 gherasima _unknown 1088 Oct 10 2007 Chapter 11 drwxr-xr-x 15 gherasima _unknown 510 Oct 11 2007 Chapter 12 drwxr-xr-x 18 gherasima _unknown 612 Oct 8 2007 Chapter 13 drwxr-xr-x 28 gherasima _unknown 952 Oct 11 2007 Chapter 14 drwxr-xr-x 13 gherasima _unknown 442 Oct 10 2007 Chapter 15 drwxr-xr-x 29 gherasima _unknown 986 Oct 11 2007 Chapter 16 drwxr-xr-x 41 gherasima _unknown 1394 Oct 13 2007 Chapter 17 drwxr-xr-x 66 gherasima _unknown 2244 Oct 13 2007 Chapter 18 drwxr-xr-x 15 gherasima _unknown 510 Oct 13 2007 Chapter 19 drwxr-xr-x 23 gherasima _unknown 782 Oct 13 2007 Chapter 20 [root@adimac pr]#
Re^2: Copy dir with space (Path::Tiny)
by McA (Priest) on Jul 10, 2014 at 13:02 UTC

    A very nice code snippet. Thank you, Anonymous Monk.