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

Hi I am new to perl and writing my first script I want to move *.txt files from one folder to another and input output folders are input , have wrote the script as below but getting errors. can anybody help here
use Getopt::Std; $usemsg = "Usage: pre_DAD.pl -i <input_folder> -w <working_dir> -o <o +utput_file> \n"; getopts('i:o:w:', \%options); if ((!exists $options{i}) || (!exists $options{o}) || (!exists $option +s{w}) ) { die $usemsg; } $inputfolder = $options{i}; $outputfile = $options{o}; $workingdir = $options{w}; #open the input directory to get a file list opendir(my $indir, $inputfolder) || die "Can't open input directory $i +nputfolder $! \n"; while (readdir $indir) { if ($_ =~ /txt$/){ my $tfn = "/".$_; move ($inputfolder.$tfn,$workingdir); } } # close the input directory closedir $indir;

Replies are listed 'Best First'.
Re: compile error in perl script
by toolic (Bishop) on Sep 21, 2016 at 18:20 UTC
    You need to post your exact error messages and your exact command line so we can see what options you passed to your script.

    My guess is one error relates to File::Copy, which has a "move" command (move is not a built-in Perl function). You probably need to add:

    use File::Copy;

    See also: Basic debugging checklist

Re: compile error in perl script (not)
by hippo (Archbishop) on Sep 21, 2016 at 22:26 UTC

    There is no compile error in your script as posted:

    $ perl -c 1172320.pl 1172320.pl syntax OK

    That's not to say there aren't runtime errors or warnings or algorithmic problems. But what you don't have are any errors in compilation.