Subject: | read method does not accept globs |
When reading from a file handle instead of a file name, the
read_with_handler method must be used with not nicely encapsulated perl
code in the handler. Example:
$cpio->read_with_handler(\*STDIN, sub {
my ($e) = @_;
push @{$cpio->{list}}, $e;
});
It would be more convenient if the read method was modified to accept
globs in addition to file names:
$cpio->read($filename);
$cpio->read(\*STDIN);
# in Cpio.pm
sub read {
my ($cpio, $filename) = @_;
my $IN;
if (ref($filename) eq 'SCALAR') {
open($IN, '<', $filename) or die "can't open $filename: $!\n";
}
elsif (ref($filename) eq 'GLOB') {
$IN = $filename;
}
else {
die "require SCALAR or GLOB for reading cpio file\n";
}
read_with_handler($cpio, $IN, sub {
my ($e) = @_;
push @{$cpio->{list}}, $e;
});
}
I have not tested the code. I just wrote it to illustrate the
implementation.