Leser: 19
1 2 3 4
use Archive::Extract; my $zipdata = Archive::Extract->new(archive => '/LOG/',[type => TYPE]); my $ok = $zipdata->extract( [to => '/LOG/'] || die $zipdata->error;
1 2 3 4
use Archive::Extract; my $zipdata = Archive::Extract->new(archive => '/LOG/DATEI.zip'); my $ok = $zipdata->extract( to => '/LOG') || die $zipdata->error;
2010-05-05T15:04:50 GwenDragongerade getestet unter Windows, klappt.
QuoteKey 'archive' (/LOG/a.zip) is of invalid type for 'Archive::Extract::new' provided by ANON at zip.pl line
3
Can't call method "extract" on an undefined value at zip.pl line 4.
QuoteIt looks like you don't have a C compiler on your PATH, so you will not be
able to compile C or XS extension modules. You can install GCC from the
MinGW package using the Perl Package Manager by running:
ppm install MinGW
2010-05-05T14:54:53 GwenDragonOha, kleine Fehler drin.
Du hast wohl die Beispiele falsch aus der Doku kopiert. ;)
Quote1) TYPE? So ein Archiv-Typ gibt es nicht. Wenn schon sollte da zip drin stehen. Aber es reicht doch die Datei.
2010-05-06T07:22:41 esskarist es denn auch wirklich ne zip datei?
mach mal "print -e '/LOG/a.zip'"
QuoteUnzulässige Option - /LOG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
C:\Documents and Settings\user\Desktop\Log auswerten\Subfiles\entzippen>print -e 'LOG/a.zip
Unzulässige Option - /a.zip
C:\Documents and Settings\user\Desktop\Log auswerten\Subfiles\entzippen>dir
05.05.2010 16:08 <DIR> .
05.05.2010 16:08 <DIR> ..
05.05.2010 15:57 <DIR> LOG
05.05.2010 16:08 <DIR> path
06.05.2010 08:19 298 zip.pl
06.05.2010 08:18 302 zip.pl.bak
2 Datei(en) 600 Bytes
4 Verzeichnis(se), 83.740.446.720 Bytes frei
C:\Documents and Settings\user\Desktop\Log auswerten\Subfiles\entzippen>cd LOG
C:\Documents and Settings\user\Desktop\Log auswerten\Subfiles\entzippen\LOG>dir
05.05.2010 15:57 <DIR> .
05.05.2010 15:57 <DIR> ..
05.05.2010 15:46 1.012 a.zip
1 Datei(en) 1.012 Bytes
2 Verzeichnis(se), 83.729.698.816 Bytes frei
2010-05-06T07:53:24 reneeWenn Du im Programm "/LOG/a.zip" schreibst, dann ist das ein absoluter Pfad. Gibt es einen Ordner "LOG" direkt im Laufwerk (also z.B.: C:\LOG\)? So wie Du das willst, musst Du einen relativen Pfad angeben, also "./LOG/a.zip".
1 2 3 4 5 6 7 8
foreach $zipfile (@zipdata) { $zipfile2= "./LOG/$zipfile"; my $zd = Archive::Extract->new(archive => $zipfile2); my $ok = $zd->extract( to => './LOG') || die $zd->error; @file=File::Spec->catfile( $to, $zd->files->[0] ); print @file; } exit;
QuoteConcatenate one or more directory names and a filename to form a complete path ending with a filename
@file = map{ File::Spec->catfile( $to, $_ ) } @{ $zd->files };
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
use Archive::Extract; my @zipdata=&all_data("LOG/","zip","zip"); #Namen der vorhandenen Zipdateien im Ordner LOG my $zipfile2; my $count=0; $Anzzipdata = @zipdata; #Anzahl der zu durchsuchenden Dateien if($Anzzipdata>1){ print "\nEs werden $Anzzipdata Zip-Ordner entzippt..."; }else{ print "\nEs wird ein Zip-Ordner entzippt..."; } foreach $zipfile (@zipdata) { $zipfile2= "./LOG/$zipfile"; my $zd = Archive::Extract->new(archive => $zipfile2); my $ok = $zd->extract( to => './LOG') || die $zd->error; my @file = map{ File::Spec->catfile( $to, $_ ) } @{ $zd->files }; my @zip = grep (/\.zip$/,@file); foreach (@zip) { $_=substr($_,1,length($_)); #sonst wäre "/DATEINAME" @_[$count++]=$_; } if (@_ ne '') { foreach (@_) { $zipfile3 = "./LOG/$_"; #foreach-Schleife zum entfernen des / kann man löschen wenn man hier nach dem "LOG" kein "/" angibt my $zd2 = Archive::Extract->new(archive => $zipfile3); my $ok = $zd2->extract( to => './LOG') || die $zd2->error; } } } print " erfolgreich\n";