|
Hi,
I'm trying to extract zip files while using threads (using perl v5.10.0 on Windows XP), but every time I enable them the files are extracted to the current directory instead of the specified one.
For example, using two files "x.zip" and "y.zip" each one with a directory inside it (with the same basename as the archive):
use strict;
use threads;
use utf8;
use warnings;
use Archive::Extract;
use Cwd;
use English;
use File::HomeDir;
sub do_stuff {
my ($name) = @ARG;
my $archive = new Archive::Extract(archive => "$name.zip");
$archive->extract(to => File::HomeDir->my_home);
print "$name\n";
}
die if getcwd eq File::HomeDir->my_home;
my $use_threads = 1;
my %data = (
x => \&do_stuff,
y => \&do_stuff,
);
if ($use_threads) {
$data{$ARG} = threads->create($data{$ARG}, $ARG) for sort keys %data;
$data{$ARG}->join() for sort keys %data;
}
else {
$data{$ARG}->($ARG) for sort keys %data;
}
If I set $use_threads to true then the files are extracted to the current directory, otherwise they are correctly extracted to the home directory. Is this a problem with my code?
Thanks, |