Thread Archive::Zip - Can't call method "desiredCompressionLevel" on an undefined value (8 answers)
Opened by bianca at 2013-10-18 17:17

bianca
 2013-10-18 17:17
#171260 #171260
User since
2009-09-13
7016 Artikel
BenutzerIn

user image
Bekomme bei Nutzung von CPAN:Archive::Zip diese Fehlermeldung:
Can't call method "desiredCompressionLevel" on an undefined value at C:/strawberry/perl/vendor/lib/Archive/Zip/Archive.pm line 249.
Wenn ich mir das in der Archive.pm anschaue
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
sub addFile {
    my $self = shift;

    my ( $fileName, $newName, $compressionLevel );
    if ( ref( $_[0] ) eq 'HASH' ) {
        $fileName         = $_[0]->{filename};
        $newName          = $_[0]->{zipName};
        $compressionLevel = $_[0]->{compressionLevel};
    }
    else {
        ( $fileName, $newName, $compressionLevel ) = @_;
    }

dann habe ich den Eindruck, bei der Methode addFile() müsse man einige Parameter angeben.

In der Doku auf CPAN steht hingegen das:
Quote
addFile( $fileName [, $newName ] )

Append a member whose data comes from an external file, returning the member or undef. The member will have its file name set to the name of the external file, and its desiredCompressionMethod set to COMPRESSION_DEFLATED. The file attributes and last modification time will be set from the file. If the name given does not represent a readable plain file or symbolic link, undef will be returned. $fileName must be in the format required for the local file system. The optional $newName argument sets the internal file name to something different than the given $fileName. $newName, if given, must be in Zip name format (i.e. Unix). The text mode bit will be set if the contents appears to be text (as returned by the -T perl operator).

Dieser desiredCompressionLevel wird aber laut Doku auf das Member Objekt gesetzt, nicht auf das addFile() Objekt
$member->desiredCompressionLevel( 9 );

Übersehe ich etwas oder kapiere ich es nur wieder mal nicht?
Wie macht man das richtig?
10 print "Hallo"
20 goto 10

View full thread Archive::Zip - Can't call method "desiredCompressionLevel" on an undefined value