if (_eq($from, $to)) { # works for references, too
carp("'$from' and '$to' are identical (not copied)");
- # The "copy" was a success as the source and destination contain
- # the same data.
- return 1;
+ return 0;
}
if (!$from_a_handle && !$to_a_handle && -d $to && ! -d $from) {
sort, it will be read from, and if it is a file I<name> it will
be opened for reading. Likewise, the second argument will be
written to (and created if need be). Trying to copy a file on top
-of itself is a fatal error.
+of itself is an error.
If the destination (second argument) already exists and is a directory,
and the source (first argument) is not a filehandle, then the source
{
my $warnings = '';
local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
- ok copy("file-$$", "file-$$"), 'copy(fn, fn) succeeds';
+ ok !copy("file-$$", "file-$$"), 'copy to itself fails';
like $warnings, qr/are identical/, 'but warns';
ok -s "file-$$", 'contents preserved';
foreach my $right (qw(plain object1 object2)) {
@warnings = ();
$! = 0;
- is eval {copy $what{$left}, $what{$right}}, 1, "copy $left $right";
+ is eval {copy $what{$left}, $what{$right}}, 0, "copy $left $right";
is $@, '', 'No croaking';
is $!, '', 'No system call errors';
is @warnings, 1, 'Exactly 1 warning';