Search code examples
perlarchive-tar

Why does Perl's Archive::Tar run out of memory?


I am using below Perl code to list the files in tar archive. The size of the tar archive is always about 15MB.

my $file = shift;
my $tar = Archive::Tar->new("$file");
my @lists = $tar->list_files;
$tar->error unless @lists;

Executing this code gives me an error "Out of Memory". I have about 512MB in my Linux system and I dont want to increase the memory of my system. Can anyone please suggest me if this code can be modified for better performance or another code to list the files in tar archive.


Solution

  • I tried that on a large tar and got an error too. Probably a bug in libs. The following worked for me:

    @files = split/\n/, `tar tf $file`