#!/usr/bin/perl -w use strict; use File::Remove; use Shell; my $some_value = the_subrotine(@array); sub the_subroutine { my @array = @_; # then execute code that returns a value # plus some temporary files in ~/tmp/ return $somevalue; # I need to remove these files, so this is what I did # with method from Shell module - failed find ("~/tmp/ -maxdepth 1 -type f -exec rm -v {} \;"); # With method from File::Remove - also failed # remove (~/tmp/ *~); }