G
Graham Wood
I'm calling find (from File::Find) in a loop inside another subroutine
and I want to access the value of $scope in the find subroutine.
====================================================================================
sub split_files{
print_both("splitting files\n");
foreach $scope (@scopes){
print_both("\tin $scope\n");
chdir("$here/$scope"){
find(\&wanted,'.');
}
}
print_both("finished\n");
}
sub wanted{
push(@{$files{$scope}}, $File::Find::name);
}
====================================================================================
If I use
foreach my $scope (@scopes){
}
The value of scope is not accessible in wanted(). How should I scope
$scope so that wanted() can see it?
If I use a package in split_files() and $packagename::scope to get the
value in wanted(), do I then have to change every reference to
print_both() to $main:
rint_both() or is there a shorter way to do it?
Thanks
Graham
and I want to access the value of $scope in the find subroutine.
====================================================================================
sub split_files{
print_both("splitting files\n");
foreach $scope (@scopes){
print_both("\tin $scope\n");
chdir("$here/$scope"){
find(\&wanted,'.');
}
}
print_both("finished\n");
}
sub wanted{
push(@{$files{$scope}}, $File::Find::name);
}
====================================================================================
If I use
foreach my $scope (@scopes){
}
The value of scope is not accessible in wanted(). How should I scope
$scope so that wanted() can see it?
If I use a package in split_files() and $packagename::scope to get the
value in wanted(), do I then have to change every reference to
print_both() to $main:
Thanks
Graham