Search code examples
perlmove

Undefined subroutine when moving a file


My current directory is composed in this way:

currentDirectory
 - folder1
   -file1
 - folder2

In code I wrote to move file1 to folder2 this according to the File::Copy doc:

move("folder1/file1","folder2/file1");

I'm getting an error:

Undefined subroutine &main::move at script.pl line 49

Solution

  • My guess is that you either forgot to include the module with use:

    use warnings;
    use strict;
    use File::Copy;
    
    move("folder1/file1","folder2/file1");
    

    Or you have something like:

    use File::Copy qw();