package Testit; require Exporter; our @ISA = qw[ Exporter ]; our @EXPORT = qw[ forthread ]; our @VERSION = 1.0; sub forthread{ my ($arg)=@_; warn "forthread called with argument: '$arg'"; return 0; } 1; #### #! perl -w use strict; use threads; use XML::Simple; use Data::Dumper; my $data = ' Testit forthread '; my $ref = XMLin( $data ); print Dumper $ref; my $argument=1; require $ref->{thread}{module} . '.pm'; ## Line A my $thread=threads->create( \&{ $ref->{thread}{module} . '::' . $ref->{thread}{subroutine} }, # Line B $argument ); $thread->join(); exit(0); #### c:\test>test $VAR1 = { 'thread' => { 'subroutine' => 'forthread', 'module' => 'Testit' } }; forthread called with argument: '1' at Testit.pm line 11. #### &{ 'Testit::forthread' } #### \ &{ 'Testit::forthread' } #### require $ref->{thread}{module} . '.pm'; my $thread=threads->create( do{ no strict 'refs'; \ &{ $ref->{thread}{module} . '::' . $ref->{thread}{subroutine} } }, $argument ); #### require $ref->{thread}{module} . '.pm'; my $subname = $ref->{thread}{module} . '::' . $ref->{thread}{subroutine}; my $thread=threads->create( do{ no strict 'refs'; \ &{ $subname } }, $argument );