I don't know about threads and my perl is not built for threads but I can illustrate the problem by the following:
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
#When you follow the sub name with arguments in parentheses
#the sub runs first and returns a scalar value,
#which the backslash makes into a scalar reference.
say ref(\&example(1, 2, 3));#See? We have a SCALAR reference, not a CODE ref
say ref(\&example);#Now we have a CODE reference.
sub example{
my ($arg1, $arg2, $arg3) = @_; #Do something with arguments, if any
return 'example sub executed successfully';
}
d5e5
Practically a Posting Shark
810 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159