Recursive copy with processing
anjiro
created: 2006-05-01 15:04:15
I have a somewhat complicated copy process I want to do. I need to recursively copy one directory to another, doing some processing during the copy. File::Repl is exactly what I want, except that the part that I want isn't actually implemented (the Process functionality). What would be perfect would be something that looks like:
use File::IdealCopy;

my $cp = new IdealCopy(recursive => 1, rename_callback => \&rename,
  post_copy_callback => \&post);
IdealCopy("/mnt/source", "/data/dest");

sub rename
{
  return lc;
}

sub post
{
  open FP1, $_[0] or die;
  open FP2, ">$_[0].new" or die;
  while()
  {
    chomp;
    print FP2, $_ + 1, $/;
  }
  close FP1;
  close FP2;
}

Of course, there's no File::IdealCopy. Any ideas?
Re: Recursive copy with processing
created: 2006-05-01 15:08:10
Grab a copy of File::Repl, hack in the features you want, use said features. If you want, feel free to either provide the features back to the author and/or release it as your own.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

perlmonks.org content © perlmonks.org and anjiro, dragonchild

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03