in reply to shell problem

Have you looked at Archive::Tar?

Also for problems like this it can be very nice to open on pipes and hook them up within Perl.