use Getopt::Long; my %opt = (); GetOptions( \%opt, #general file path "path=s", #file name "file=s", ); my $path = $opt{path}; my $file = $opt{file}; #### my $fullFile = $path . $file; unlink($fullFile) or die "$!\n"; #### foreach my $arrayFile(@array) { my $fullFile = $path . $arrayFile; unlink($fullFile) or die "$!\n"; }