Re: I want a perl script for?




From: "Vinayak dutt" <vinayak.dutt@xxxxxxxxx>
Am vinayak here.
As am new to Perl and their is a requirment which says -
1. There exists a .zip which contains folders and file.

2. Search for 'makefile' in the respective folders and store them in a text
file.

3. And search for .c files in them and list them in separate text file.
4. Then the files that exists other than .c files should be removed from the
dir.

From which dir? You only have files in a zip archive.

Here is a perl program that reads a zip archive, extracts the makefile and ..c files, then delete the other files from the archive (if this is what you wanted to say by "from the dir").

Octavian

use strict;
use Archive::zip;

my $zip = Archive::Zip->new('lucru.zip');

my @files = $zip->memberNames;

foreach my $file(@files) {
if ($file eq 'makefile' or $file =~ /\.c$/) {
$zip->extractMember($file);
}
else {
$zip->removeMember($file);
}
}

$zip->overwrite;

.



Relevant Pages

  • Re: I want a perl script for?
    ... There exists a .zip which contains folders and file. ... And search for .c files in them and list them in separate text file. ... I think that, since you are new to Perl, it would be better to extract the ... makefile in them. ...
    (perl.beginners)
  • Parsing Path Data into Tree Structure
    ... for a way of creating a tree structure to display folders and titles ... of images contained in those folders. ... very plain text string describing a path and parse that into a tree to ... I won't bore you with since its jscript and not perl) ...
    (comp.lang.perl.misc)
  • Re: Automated file management solution
    ... Grab the PERL book and start writing... ... > automatically move the files in those folders to other named folders on ... > that customer is named with the 3-letter abbrev. ... > 3-letter abbreviation to a corresponding customer folder. ...
    (microsoft.public.windows.server.sbs)
  • Re: Perl - MultiUser Webserver Environment Help
    ... Perl interpreter only allow listings of certain files and folders to ... Please post server configuration problems in a newsgroup ...
    (comp.lang.perl.misc)
  • Re: I want a perl script for?
    ... As am new to Perl and their is a requirment which says - ... There exists a .zip which contains folders and file. ... -- Terry Pratchett in Sourcery ...
    (perl.beginners)