How can I tar multiple files in Perl?

Assuming you have worked out what files you want using File::Find then something like my @dir = qw/a b/ ; system "tar -cvf mytar @dir might work. But you might find that the command line is too long In which case maybe write the list of files to a file and use the option files-from=NAME (and please don't tell me you are not allowed to write to files).

Assuming you have worked out what files you want using File::Find then something like my @dir = qw/a b/ ; system "tar -cvf mytar @dir" ; might work. But you might find that the command line is too long. In which case maybe write the list of files to a file and use the option --files-from=NAME (and please don't tell me you are not allowed to write to files).

It will break if any of the file names include a character with special meaning for the shell. Provide arguments as the list after the PROGRAM argument. – Quentin Mar 30 '10 at 23:10 presumably you are referring to my first suggstion.

The files in --file-from would be safe against that. – justintime Mar 31 '10 at 2:29.

I'd use Archive::Tar and populate @filelist with Class::Path (specifically Class::Path::Dir's recurse method).

I cannot use Archive::Tar, because I am using system call to create a tar file(its the requirement) $tarExe = "$toolDir/bin/gnu_tar/${binPlatform}/tar. Exe"; system("${tarExe} -cvf $tarname $location"); – superstar Mar 30 '10 at 14:33 1 You have a requirement to do it the hard way? There is no good reason to do that on a real project.Is this homework?

– Quentin Mar 30 '10 at 14:35 I need to use tar. Exe from the winx64 folder to create the tar file. This is standard method I was suggested to do.

Its a real project to create tar files. – superstar Mar 30 '10 at 14:38 3 Using a Perl module is the standard way to do things in Perl, shelling out to other binaries is not. – Quentin Mar 30 '10 at 14:42 4 If it was a suggestion, then you don't have to do it that way.

Do it the right way instead. – Quentin Mar 30 '10 at 14:51.

If for some reason you cannot, or are not permitted to, install additional modules beyond the base system you could use File::Find instead of Class::Path. It sounds like you already know how to call out to the system tar command so I'll leave it at that.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions