use File::Find; find (\&doSomething,'.'); # Find stuff in curr dir, execute subroutine do something on match. (\&[name] is a subroutine pointer... ) exit(0); # not needed sub doSomething{ my $fn = $_; # also not needed but makes life easy if ((!(-d $fn)) && ($fn =~/tar$/i)){ # -d test not really necessary system("tar","-xvf",$fn); # May want to do a which tar if it doesn't work ... } }