use strict; use Archive::Tar; use File::Path qw(make_path remove_tree); my $file = '/home/rocket/sample.tgz'; my $dir = '/var/tmp/extract'; make_path("$dir") unless -d "$dir"; chdir($dir); my $ocs = Archive::Tar->new($file); my $stat = $ocs->extract(); print $stat;