Long time no see monks! Ok, I'm back and this time I'm more powerful than an ancient who just got force-descended by the full-ascended; and, I've got a galactic problem.

I can't figure out why Arhive::Zip is broken, here is a test case, someone fix this for me, and I will grace you all with more divine knowledge about the mighty power of tabs, and the evilness of the dark spaces horde.

Picture here

Note, this is my first perl test, if anyone excessively bitches I will write lots of code and not make any more tests, khtnksxzs

Problem found

Archive::Zip isn't $\ safe, #!/usr/bin/perl -l threw it off.

#!/usr/bin/perl -l use strict; use warnings; use Archive::Zip qw( :ERROR_CODES ); use Digest::MD5; use Test::More tests => 5; use Carp; use constant ERROR_PRONE_FILE => 'error.jpg'; use constant ERROR_FILE => 'corrupterror.jpg'; use constant ERROR_ARCHIVE => 'out.zip'; my $zip = Archive::Zip->new(); my ( $before, $after ); ## ## OPEN GOOD FILE GET MD5 ## { my $md5 = Digest::MD5->new; open ( my $fh, '<', ERROR_PRONE_FILE ) or die 'Can not open file' ; binmode( $fh ); $before = $md5->addfile( $fh )->md5_hex; close $fh; } ## ## Zip up and write out ## { my $md5 = Digest::MD5->new; $zip->addFile( ERROR_PRONE_FILE ); $zip->extractMember( ERROR_PRONE_FILE, ERROR_FILE ); open ( my $fh, '<', ERROR_FILE ) or die 'Can not open file' ; binmode( $fh ); $after = $md5->addfile( $fh )->md5_hex; close $fh; unlink ERROR_FILE; cmp_ok( $after, 'eq', $before , 'Failed test, pre-zip, and post-pre-zip do not match' ); my $status = $zip->writeToFileNamed( ERROR_ARCHIVE ); cmp_ok( $status, '==', AZ_OK, 'Wrote zip out alright' ); } ## ## Read back ## { my $md5 = Digest::MD5->new; my $zip2; eval { $zip2 = Archive::Zip->new( ERROR_ARCHIVE ); }; ok( !$@, "This stupid bugger crashed again, error:\n$@" ); ok ( defined $zip2, 'Perl failed at spawning the object of doom' ) +; $zip2->extractMember( ERROR_PRONE_FILE, ERROR_FILE ); open ( my $fh, '<', ERROR_FILE ) or croak 'Can not open file' ; binmode( $fh ); $after = $md5->addfile( $fh )->md5_hex; close $fh; unlink ERROR_FILE; unlink ERROR_ARCHIVE; cmp_ok( $after, 'eq', $before , 'Failed test, pre-zip, and post-zip do not match' ); } print "Success sums match up all th way through!! Congrats"; print "Verbose: [ $before eq $after ]"; 1;


Evan Carroll
www.EvanCarroll.com

In reply to .o0O [(i^% Archive::Zip test %^i)]O0o. by EvanCarroll

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.