#!/usr/bin/perl -w use strict; use Archive::Tar; die "Provide the name of the tar file, please!\n" unless $ARGV[0]; my $tar = Archive::Tar->new(); $tar->read( $ARGV[0], 0 ); @_ = $tar->list_files(); my @files = sort { $b cmp $a } @_; foreach ( @files ) { if ( -d ) { rmdir or warn "$_ is not empty (sharred path)\n"; next; } unlink; }