in reply to Re^3: Copying files between directories. How can I improve this code.
in thread Copying files between directories. How can I improve this code.

Thats more then I expected, Thankyou.

my $subTree = substr $File::Find::name, 1 + length $path;

I see this string declares subtree and initialises it as the name of the file currently in Find. I'm not sure what this does 1 + length $path

Does it change the value of $path to 1$path for the first folder.

Actually I know, it uses substr to pullout the part of $File::Find::name after the last /.

Replies are listed 'Best First'.
Re^5: Copying files between directories. How can I improve this code.
by GrandFather (Saint) on Apr 22, 2006 at 08:54 UTC

    substr takes up to four parameters. A string, a start offset, a length and a replacement string. In this case, given a string and an offset, it returns the contents of the string from the offset to the end of the string. The statement is slicing the original path off the front of the actual path to the file and retaining the subdirectory path (if any).

    Take a look at the code and at the output and you should be able to infer what is going on.


    DWIM is Perl's answer to Gödel