Skip Menu |
 

This queue is for tickets about the Archive-Tar CPAN distribution.

Report information
The Basics
Id: 104196
Status: open
Priority: 0/
Queue: Archive-Tar

People
Owner: Nobody in particular
Requestors: Harald.Joerg [...] arcor.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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)
Download (untitled) / with headers
text/plain 1.3k
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
Download (untitled) / with headers
text/plain 1.6k
I confirm this report, with one little correction inline. On Sun May 03 16:17:58 2015, Harald.Joerg@arcor.de wrote: Show quoted text
> 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
Should use underscore rather than hyphen: my @file_names = Archive::Tar->extract_archive($ARGV[0]); # list of files Show quoted text
> ---------------------------------------------------------------------- > > 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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.