I have the following line of code:
my $id = async { &PopulateIndustryCompanyJobs($sIndustryName, $nThread);
$qCompleted->enqueue($sIndustryName); }
It causes this error:
Prototype mismatch: sub main::async (&;@) vs (&) at c:/Perl/lib/Exporter.pm
line 65.
Here is the line of source code from my ActiveState Perl distribution 5.8+:
*{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;
I have two questions:
(1) What the heck does that line of code do? We are assigning a reference of
a function in some package to a typeglob? What do all the {} do? What is the
\:: for? Why the quotes?
(2) Am I doing something wrong? My program seems to work. What should I
change?
Thanks again,
Siegfried
Below is the full code. Line 65 is nearly the last line of code.
----------------------------------------------------------------------------
----------------------------------------------
sub import {
my $pkg = shift;
my $callpkg = caller($ExportLevel);
if ($pkg eq "Exporter" and @_ and $_[0] eq "import") {
*{$callpkg."::import"} = \&import;
return;
}
# We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-(
my($exports, $fail) = ([EMAIL PROTECTED]"$pkg\::EXPORT"}, [EMAIL
PROTECTED]"$pkg\::EXPORT_FAIL"});
return export $pkg, $callpkg, @_
if $Verbose or $Debug or @$fail > 1;
my $export_cache = ($Cache{$pkg} ||= {});
my $args = @_ or @_ = @$exports;
local $_;
if ($args and not %$export_cache) {
s/^&//, $export_cache->{$_} = 1
foreach (@$exports, @{"$pkg\::EXPORT_OK"});
}
my $heavy;
# Try very hard not to use {} and hence have to enter scope on the
foreach
# We bomb out of the loop with last as soon as heavy is set.
if ($args or $fail) {
($heavy = (/\W/ or $args and not exists $export_cache->{$_}
or @$fail and $_ eq $fail->[0])) and last
foreach (@_);
} else {
($heavy = /\W/) and last
foreach (@_);
}
return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy;
local $SIG{__WARN__} =
sub {require Carp; &Carp::carp};
# shortcut for the common case of no type character
*{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;
}