Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Issue with File::Copy and move

by hippo (Bishop)
on Sep 12, 2020 at 14:41 UTC ( [id://11121670]=note: print w/replies, xml ) Need Help??


in reply to Issue with File::Copy and move

This is perl 5.32 on fedora 32

Using an older version of File::Copy (2.30) my SSCCE shows that the source file still exists. Perhaps try running this and see what happens?

use strict; use warnings; use Test::More tests => 4; use File::Copy 'move'; # Create a file my $src = '/tmp/foo.txt'; my $destdir = '/flurble'; open my $tmp, '>', $src or die $!; print $tmp "Hello, world!\n"; close $tmp; ok -e $src, "Source file $src exists"; ok ! -d $destdir, "Destination directory $destdir does not exist"; ok ! move ($src, "$destdir/bar.txt"), 'Move fails as expected'; ok -e $src, "Source file $src still exists";

Update: fixed open statement to use the $src variable.


🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121670]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-23 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found