in reply to Re^4: manipulating cpio archive
in thread manipulating cpio archive

Well, Perl doesn't think so. Maybe it has whitespace at the end of the archive name? Maybe post the actual output of Data::Dumper?

Interestingly enough, Archive::Cpio contains no call to binmode. I'm not sure whether it will work on Windows at all.

Replies are listed 'Best First'.
Re^6: manipulating cpio archive
by Anonymous Monk on Jan 17, 2011 at 20:06 UTC
    OK, you asked for it (no sarcasm intended):
    $VAR1 = bless( { 'list' => [ bless( { 'mode' => 16877, 'nlink' => 2, 'ino' => 63796, 'rdev' => 0, 'dev' => 2056, 'uid' => 1000, 'mtime' => 1295288664, 'name' => '.', 'data' => undef, 'gid' => 1000 }, 'Archive::Cpio::File' ), bless( { 'mode' => 33188, 'nlink' => 1, 'ino' => 63800, 'rdev' => 0, 'dev' => 2056, 'uid' => 1000, 'mtime' => 1295288664, 'name' => 't2', 'data' => undef, 'gid' => 1000 }, 'Archive::Cpio::File' ), bless( { 'mode' => 33188, 'nlink' => 1, 'ino' => 63799, 'rdev' => 0, 'dev' => 2056, 'uid' => 1000, 'mtime' => 1295288664, 'name' => 't1', 'data' => undef, 'gid' => 1000 }, 'Archive::Cpio::File' ), bless( { 'mode' => 33188, 'nlink' => 1, 'ino' => 63801, 'rdev' => 0, 'dev' => 2056, 'uid' => 1000, 'mtime' => 1295288664, 'name' => 't3', 'data' => undef, 'gid' => 1000 }, 'Archive::Cpio::File' ) ], 'archive_format' => bless( { 'magic' => 29127 }, 'Archive::Cpio::OldBina +ry' ) }, 'Archive::Cpio' );

      I would asume that this is a bug in Archive::Cpio. The ->remove subroutine treats $archive->{list} as an array of strings (as do the examples), but it contains Archive::Cpio::File objects that don't seem to have stringification overload.

      You'll likely need to rewrite the ->remove method to actually remove elements by their ->name (and raise a bug against the module, please).

      The test suite only tests that the (main) module can be loaded and tests no functionality at all, so adding a test for ->remove wouldn't hurt either.

        Thank you.
        You put it more precise, but I already concluded that the code could not be right. I hope a fix will be made, there is an outstanding bug 2 years old. This code is a bit over my head.