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 ... } } #### undef$/;$mmm="J\nutsu\nutss\nuts\nutst\nuts A\nutsn\nutso\nutst\nutsh\nutse\nutsr\nuts P\nutse\nutsr\nutsl\nuts H\nutsa\nutsc\nutsk\nutse\nutsr\nuts";open($DOH,"<",\$mmm);$_=$forbbiden=<$DOH>;s/\nuts//g;print;