Skip Menu |

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

Report information
The Basics
Id: 52640
Status: open
Priority: 0/
Queue: Archive-Extract

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

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



Subject: Make all the globals object attributes
It would be very nice if I could safely change the behavior of an Archive::Extract object without having to localize globals before every use. For example: my $ae = Archive::Extract->new( archive => $file, prefer_bin => 1 ); ...and then later... $ae->extract( to => $dir ); as opposed to: my $ae = Archive::Extract->new( archive => $file, ); ...and then later... local $Archive::Extract::PREFER_BIN = 1; $ae->extract( to => $dir ); This would apply to debug, warn and prefer_bin. The object would use the global flags as a defaults.
And here's a patch. There's a few wacky localized uses of $WARN in the code that I don't know what to do with.

Message body is not shown because it is too large.

On Thu Dec 10 01:33:20 2009, MSCHWERN wrote: Show quoted text
> It would be very nice if I could safely change the behavior of an > Archive::Extract object without having to localize globals before every > use. For example: > > my $ae = Archive::Extract->new( > archive => $file, > prefer_bin => 1 > ); > > ...and then later... > $ae->extract( to => $dir ); > > as opposed to: > > my $ae = Archive::Extract->new( > archive => $file, > ); > > ...and then later... > local $Archive::Extract::PREFER_BIN = 1; > $ae->extract( to => $dir ); > > This would apply to debug, warn and prefer_bin. The object would use > the global flags as a defaults.
This would be backwards incompatible however; the value of 'prefer_bin' for extract would now be set at ->new time, not at ->extract time as in your previous example. Meaning the old code of: Show quoted text
> my $ae = Archive::Extract->new( archive => $file ); > local $Archive::Extract::PREFER_BIN = 1; > $ae->extract( to => $dir );
would not actually use the commandline tools. I'm happy to take the patch if the old behaviour can be supported as well. This probably means checking if ->new( prefer_bin ... ) was passed at ->extract time. Thanks for the patch and the clear UI improvement that you suggest.