#!/usr/bin/perl -w use warnings; use LWP 5.66; my $browser = LWP::UserAgent->new; $browser -> timeout(900); use CGI qw(:standard); print header, start_html( -title=> 'Page 1' , -bgcolor=>'#eeeeee'), p(h1({-align=>CENTER},'Trial')) ; @files1 = glob ("../Results/*.txt");#collect all the files into an array foreach my $file (@files1) { print p("s $file"); if ($file=~/(\S+)[\/](\S+)[\/](\S+).*/g) { print p("to $3"); unlink("$3"); if (unlink($3) == 0) { print "$3 deleted."; } else { print "File was not deleted."; } my $FileToWrite = "../Results/"; open (PearsonResult,">>$FileToWrite$3") || die "couldn't open the file $!"; print PearsonResult ("test\n "); close PearsonResult || die "can't close:$!"; } } print end_html;