in reply to Broken Function
#!/usr/bin/perl # Untested! use Path::Tiny; my @files = ( ... ); sub find_files { my $filename = shift; my $path = 'Path::Tiny'->cwd; my $file = path($filename)->basename; if (-e $filename) { path($filename)->copy("$path/$file"); } else { open my $OUT, '>', "$path/$file" or die $!; print {$OUT} "Unable to find $filename\n"; } }
Note that -e returns true for directories, too, so you might need a different test (-f maybe?). Also, you should check the return value of copy.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Broken Function ( Path::Tiny spew )
by Anonymous Monk on Apr 05, 2014 at 08:23 UTC |