Alex Rivera | Logout

How can I archive a directory in Perl like tar does in UNIX?

Asked 2009-02-05T11:46:33.973
9

I want to archive a directory (I don't know whether I can call "I want to tar a directory"). I want to preserve the access permissions at the other end when I un-tar it. I should I tackle this problem in perl.

Thanks for the response but why I'm asking for doing it Perl is I want it independent of the platforms. I want to transfer one big file to multiple machines. Those machines can be of any platform. I should be able to untar this tar file properly right? So I want to write my own tar and untar programs. Why I'm using Perl is to make it platform independent. So I can not use tar command by opening the shell in script and stuff like that. The Archive::Tar module only deals with tarred file but it has no option to archive files.

Edit
Report

1 Answer

3

You can use the Archive::Tar Perl module, or you can execute tar directly.

If you run with the option of using tar from the commandline, use the -p flag to preserve permissions.

If you are literally just looking to tar up the directory, I'd just run the command directly, you don't need to use Perl. If you need to do some fancy processing afterwards, maybe you should. It depends.

answered 2009-02-05T11:52:35.490

Your Answer