#!/usr/bin/perl use strict; use warnings; use File::Path; use File::Basename; use File::Spec; use File::Copy; use Cwd; use Getopt::Long; # make output unbuffered $| = 1; my $path = getcwd; my $mtime = 1; my $dest; my $verbose = ''; my $showhelp = ''; my $result = GetOptions("source=s" => \$path, "mtime=i" => \$mtime, "dest=s" => \$dest, "help" => \$showhelp, "verbose" => \$verbose); # DEBUG # print "\$path = $path\n\$mtime = $mtime\n\$dest = $dest\n\$showhelp = $showhelp\n\$verbose = $verbose\n"; # exit(0); my $usage = "Usage: $0 --dest \n\t" . "[--source | --mtime | --verbose] [--help]\n\t" . "Type $0 --help for more information."; my $help = <canonpath(File::Spec->catdir($dest, $directories)); unless (exists $dirs_created{$new_dir}) { $dirs_created{$new_dir} = mkpath($new_dir); print "Created $new_dir\n" if $verbose; } copy($_, File::Spec->catfile($new_dir, "$filename$suffix")); print File::Spec->catfile($new_dir, "$filename$suffix") . "\n" if $verbose; } exit(0);