Home: Perl Programming Help: Beginner:
unlink error trying to remove files



cmccabe1
Novice

Mar 26, 2015, 11:53 AM


Views: 7747
unlink error trying to remove files

Trying to remove files from a directory using:


Code
remove() { 
printf "\n\n"
printf "Removing old files, please wait ";
use strict;
use warnings;
my $dir = "$ENV{HOME}'C:\Users\cmccabe\Desktop\annovar'";
unlink glob "$dir/out_position.txt";
unlink glob "$dir/out_parse.txt";
printf "\n Old files removed, Goodbye! \n\n"; sleep 2 && exit
}


but getting an error. I am using the perl command as part of a bash menu in cygwin. Thank you :).

Error:

Code
use: command not found 
my: command not found

Unlink extra operand /out_position.txt
Unlink extra operand /out_parse.txt



FishMonger
Veteran / Moderator

Mar 26, 2015, 12:07 PM


Views: 7742
Re: [cmccabe1] unlink error trying to remove files

Obviously using perl code directly in a bash script isn't going to work. Bash doesn't now how to execute perl code, but it can execute a perl script.

And, why do you have a beginner level question in the intermediate section? I'm moving this thread for you.