in reply to $1 not getting applied to reg ex

When you previewed your post and you saw the message saying:

If something looked unlike you expected it to you might need to check out Writeup Formatting Tips

Did you _really_ like the way your post looked?

It's hard to read your code with it formatted as badly as it is, but I strongly suspect that you are trying to reinvent File::Find. And you'd probably be better off using the original File::Find instead.

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

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

Replies are listed 'Best First'.
Re^2: $1 not getting applied to reg ex
by drum1981 (Novice) on Jul 26, 2005 at 14:41 UTC
    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

      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.