Professional Web Applications Themes

Archiving folder containing folders (was - Using archive::tar for archiving a folder) - PERL Beginners

Thanks for the response David. When I do 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.pl"))' it tars all the .pl files in the current working directory. However, I need to tar a folder which has many folders inside it. I tried 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.*"))' and 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*"))' But both gave only the files in the current folder and did not recurse inside it. How do I archive a folder with many folders inside ? (perhaps the key lies in glob...i searched but couldn't find a flag to make it recurse) Thanx in advance aman -----Original Message----- From: david [mailto:dzhuolooksmart.net] Sent: 11 February 2004 00:34 To: [email]beginnersperl.org[/email] Subject: Re: Using ...

  1. #1

    Default Archiving folder containing folders (was - RE: Using archive::tar for archiving a folder)

    Thanks for the response David.

    When I do 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.pl"))' it
    tars all the .pl files in the current working directory.

    However, I need to tar a folder which has many folders inside it.

    I tried 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.*"))' and
    'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*"))'

    But both gave only the files in the current folder and did not recurse
    inside it.

    How do I archive a folder with many folders inside ? (perhaps the key lies
    in glob...i searched but couldn't find a flag to make it recurse)

    Thanx in advance
    aman



    -----Original Message-----
    From: david [mailto:dzhuolooksmart.net]
    Sent: 11 February 2004 00:34
    To: [email]beginnersperl.org[/email]
    Subject: Re: Using archive::tar for archiving a folder


    Aman Thind wrote:
    > Hello Friends,
    >
    > I wish to archive a folder into a .tar
    >
    > I've been searching through the doentation of archive::tar module but
    > could not find a way by which I could make the .tar just by specifying the
    > folder name (like on unix prompt "tar -cvf myarchive.tar myfoldername")
    > and not explicitly stating the filenames.
    Archive::Tar has a class method that does exactly like that:

    [panda]$ perl -MArchive::Tar -e \
    'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.pl"))'

    [panda]$ ls -l /tmp
    -rw-r--r-- 1 x x 9216 Feb 10 10:59 test.tar

    arguments to create_archive:

    1. name of the archive you want to create. in your example, it would be
    myarchive.tar

    2. compression level from 2 to 9. any other values will use the default
    level.

    3. a list of files to add to the archive. in my example above, all files
    ending in .pl will be archived to /tmp/test.tar

    david
    --
    sub'_{print"_ ";* \ = * __ ,\ & \}
    sub'__{print"_ ";* \ = * ___ ,\ & \}
    sub'___{print"_ ";* \ = * ____ ,\ & \}
    sub'____{print"_,\n"}&{_+Just}(another)->(Perl)->(Hacker)

    --
    To unsubscribe, e-mail: [email]beginners-unsubscribeperl.org[/email]
    For additional commands, e-mail: [email]beginners-helpperl.org[/email]
    <http://learn.perl.org/> <http://learn.perl.org/first-response>

    Aman Thind Guest

  2. #2

    Default Re: Archiving folder containing folders (was - RE: Using archive::tar for archiving a folder)

    On 02/11/04 06:39, Thind, Aman wrote:
    > Thanks for the response David.
    >
    > When I do 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.pl"))' it
    > tars all the .pl files in the current working directory.
    >
    > However, I need to tar a folder which has many folders inside it.
    >
    > I tried 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.*"))' and
    > 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*"))'
    >
    > But both gave only the files in the current folder and did not recurse
    > inside it.
    >
    > How do I archive a folder with many folders inside ? (perhaps the key lies
    > in glob...i searched but couldn't find a flag to make it recurse)
    >
    something like the (untested) code below should work:

    use Archive::Tar;
    use File::Find;

    use strict;
    use warnings;

    my files;
    find sub {
    return if -d;
    push files, $File::Find::name;
    }, 'Module-Build'

    Archive::Tar->create_archive( 'test.tar', files );
    Randy W. Sims Guest

Similar Threads

  1. Archiving
    By jazzcar in forum Macromedia Contribute General Discussion
    Replies: 1
    Last Post: June 5th, 11:45 PM
  2. Help with archiving in perl.
    By dcatdemon in forum PERL Modules
    Replies: 1
    Last Post: April 26th, 12:50 PM
  3. Archiving in 7
    By BaileyBurger in forum Coldfusion Server Administration
    Replies: 1
    Last Post: May 22nd, 03:28 PM
  4. Archiving Solutions
    By igalloway@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 7
    Last Post: March 3rd, 01:39 AM
  5. Using archive::tar for archiving a folder
    By Aman Thind in forum PERL Beginners
    Replies: 1
    Last Post: February 10th, 07:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139