http://www.perlmonks.org?node_id=11128782

DAN0207 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to match the regex of the filename and if it matches i want to move the file into another directory.But when i run the script, i get the error as "move failed: Invalid cross-device link".Please help me.The code is given below:

#!/usr/bin/perl -w use File::Copy; $InDir = $ARGV[0]; $OutDir = $ARGV[1]; if (!opendir(DIR,$InDir)) { print "Bad Dir $InDir\n"; exit 1;} while(my $Infile = readdir(DIR)) { if ($Infile =~ 'F\d{8}\.\d{4}\+\d{4}\-\d{4}\+\d{4}_.*') { move("$Infile", "$OutDir") or die "move failed: $!"; } elsif ($Infile =~ 'F\d{8}\.\d{6}\+\d{4}\-\d{6}\+\d{4}_.*' ) { <.....do something........> } }