in reply to Re: $1 not getting applied to reg ex
in thread $1 not getting applied to reg ex

hi hows it going. this code is actually meant to transfer some directories along with their sub contents to another directory. basically i am looking at 6 or so base directories, of the form say C:/base_dir/5_digit_number/contents. i need to move them to C:/new_folder/5_digit_number/base_dir_name/contents. once i go through the other base directories they will have directories with the same 5 digit numbers, but different contents, and it would add a new directory within 5_digit_number with its contents, and so on so forth. if you have any thoughts on what i am doing incorrectly, please let me know. thanks

Replies are listed 'Best First'.
Re^3: $1 not getting applied to reg ex
by davorg (Chancellor) on Jul 26, 2005 at 15:03 UTC

    So I was right. You _are_ trying to reinvent File::Find :)

    I think you want something a bit like this (but I haven't had a chance to test it)

    #!/use/bin/perl use strict; use warnings; use File::Find; use File::Path; use File::Copy; @_ >= 2 or die "Usage: $0 <source_dir> <dest_dir>\n"; my ($src, $dest) = @_; find(\&do_this, $src); sub do_this { if (-d) { mkpath([$File::Find::name]); } else { my $new = $File::Find::name; $new =~ s|/$src/|/$dest/|; copy $_, $new; } }
    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      hello. i must appologize. i am just a novice. i am having trouble manipulating your code snipet here, and well, i am not sure i fully understand it. would you be able to send me some comments on it. if you like you can email it to me at rgdsouza@gmail.com. thanks once again.

        If you need private consultancy then I'm more than happy to send you my rate card. Otherwise, please post your questions here and we'll all do what we can to help you.

        --
        <http://www.dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg