Perl move causes an error but moves the file

I am new to perl and just found very unexpected behavior.

I use transition from File::Copyto rename a folder. It works as expected, but when I look at the return value variable $!after that, it shows an error.

Relevant code that I use:

$helpr =~ s/\./ /g;

move($file,$helpr);
print $!;

Exit:

[j@box test]$ ls
my.test.dir
[j@box test]$ fileRenamer.pl
No such file or directory
[j@box test]$ ls
my test dir

Why do I get an error code when the work is done? What am I missing?

Thanks everyone!

+4
source share
2 answers

As mpapec says, you shouldn't use an error message unless moveit returns false, for example. a ... or die $!. However, why is this happening:

, , File::Copy $!. :

($tosz1,$tomt1) = (stat($to))[7,9];

$to - , . , , , , , $!. .

+6

$! , move() ( false),

move($file,$helpr) or print $!;
+3

All Articles