The only flaw of the old code is that it directly compares elements from @{ $cpio->{list} } against the filenames. That is wrong because the elements in @{ $cpio->{list} } are Archive::Cpio::File objects. Instead, it should compare the elements against the ->name property. Most likely (but untested) like so:
sub remove { my ($cpio, @filenames) = @_; $cpio->{list} or die "can't remove from nothing\n"; # Create a lookup table of names to be removed my %filenames = map { $_ => 1 } @filenames; # This was the old, buggy code # @{$cpio->{list}} = grep { !$filenames{$_} } @{$cpio->{list}}; # Remove the elements according to their name: @{$cpio->{list}} = grep { !$filenames{$_->name} } @{$cpio->{list}} +; }
In reply to Re^10: manipulating cpio archive
by Corion
in thread manipulating cpio archive
by momo33
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |