#!/usr/bin/perl my $frompath = "/home/scr"; my $topath = "/home/scr"; chomp(@mypath = `ls $frompath/DVD*/Packages/*.tar`); my $mycwd=`pwd`; foreach $test (@mypath) { if ($test =~ m/(DVD\d)/ ) { my $toloc = "$topath/$1/Packages"; "chdir $toloc or dir qq(can't chdir $toloc $!\n);" my $result = `/usr/bin/tar -xvpf $test`; } } "chdir $mycwd or dir qq(can't chdir $toloc $!\n);"