in reply to How come I cannot delete file with unlink

Your main problem is that the '' in the unlink line don't evaluate the variable.

You need unlink $FileName in the last line.

It will tell you how many files it deleted, and you could report this.

sub DeleteFile() { my $FileName = $_[0] . $t; $ret = unlink $FileName; die "No file called [$Filename] deleted\n" unless $ret == 1; }
or, more concisely
sub DeleteFile() { my $FileName = $_[0] . $t; die "No file called [$Filename] deleted\n" unless unlink $FileName; }

Update: added third option.

or, you can be more friendly and return the value to the caller :

sub DeleteFile() { my $FileName = $_[0] . $t; my $ret = unlink $FileName; warn "No file called [$Filename] deleted\n" unless $ret; return $ret; }
Which of the last 2 to choose depends on how important it is that the file is deleted or whether you have already checked its existence.
--
Brovnik