http://qs321.pair.com?node_id=1032261


in reply to File deletion

Hi,

It is very easy in Perl.Use the below steps:

use strict; my $file_location = shift; open(FH,">","log.txt") or die "unable to open file log.txt"; my @files = <$file_location/*>; foreach my $file (@files){ system("rm $file"); unless( $? == -1 ){ print FH "\n$file is deleted.."; } else{ print FH "\n$file is not deleted.. $!"; } } close FH;


Thanks marto for pointing out the error , updated the code, now working correctly.