Subject: | Archive::Tar extract method returns file objects, not file names |
Date: | Sun, 03 May 2015 22:17:28 +0200 |
To: | bug-archive-tar [...] rt.cpan.org |
From: | Harald.Joerg [...] arcor.de (Harald Jörg) |
Hello Perl / Archive::Tar maintainers,
Not urgent: Archive::Tar doesn't behave as documented, but I am not sure
whether the docs or the code represent the intended behaviour:
The extract() object method is documented
"Returns a list of filenames extracted."
but in fact it returns a list of Archive::Tar::File objects.
The class method extract-archive, however, returns file *names*, as
well as the read() object method with option {extract=>1}.
Sample code:
----------------------------------------------------------------------
#!/usr/bin/perl
my $tar = Archive::Tar->new($ARGV[0]);
my @file_objects = $tar->extract(); # list of Archive::Tar::File objects
my @file_names = Archive::Tar->extract-archive($ARGV[0]); # list of files
----------------------------------------------------------------------
If extract() should behave as documented, it needs just a one-line patch:
----------------------------------------------------------------------
$ diff -U2 /usr/share/perl/5.18/Archive/Tar.pm ../lib/Archive/Tar.pm
--- /usr/share/perl/5.18/Archive/Tar.pm 2014-03-27 19:47:38.000000000 +0100
+++ ../lib/Archive/Tar.pm 2015-05-03 21:59:09.809164876 +0200
@@ -650,5 +650,5 @@
}
- return @files;
+ return map { $_->full_path } @files;
}
----------------------------------------------------------------------
--
Cheers,
haj