in reply to Re^2: cp in perl
in thread cp in perl
But since File::Copy::copy is usually promoted as "Perl's replacement for cp", people will expect it to behave as cp. And not study the documentation carefully.
You for instance either didn't study the documentation carefully, or if you did, forgot it. Because you wrongly assumed File::Copy::copy only takes two arguments. Now your mistake isn't as costly as forgetting the meaning of the third parameter. But if you can forget File::Copy::copy having a third parameter, you might as well forget that File::Copy::copy acts the same as cp when given two arguments, but very, very different when given three.
Now had you used your systems 'cp', it would have copied all three files into /tmp.use File::Copy; my @files1 = qw [foo]; my @files2 = qw [bar baz]; my $dir = "/tmp"; copy @files1, $dir; # No problem. copy @files2, $dir; # File::Copy will warn, but erase 'baz' anyw +ay.
And had you used an all numeric $dir in the above code fragment, File::Copy::copy would have overwritten baz without so much as a warning.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: cp in perl
by Fletch (Bishop) on Nov 07, 2006 at 14:50 UTC | |
by Hofmator (Curate) on Nov 08, 2006 at 07:27 UTC | |
by Anonymous Monk on Nov 07, 2006 at 16:37 UTC |