hi experts, my code is as simple as the follow. use Thread; $thr = new Thread \&sub1; # Spawn the thread $thr->detach; # Now we officially don't care any more sub sub1 { $a = 0; while (1) { $a++; print "\$a is $a\n"; sleep 1; } } however, when i compile it. The error occur stating "Undefined subroutine &threads::new called at sample_thread.pl line 2.". What is the reason?
janicehwang1325@yahoo.com wrote: > hi experts, > > my code is as simple as the follow. > > use Thread; > $thr = new Thread \&sub1; # Spawn the thread Try: $thr = Thread->new(\&sub1); > $thr->detach; # Now we officially don't care any more > > sub sub1 { > $a = 0; > while (1) { > $a++; > print "\$a is $a\n"; > sleep 1; > } > } > > > however, when i compile it. The error occur stating "Undefined > subroutine &threads::new called at sample_thread.pl line 2.". What is > the reason? -- Brian Wakem Email: http://homepage.ntlworld.com/b.wakem/myemail.png
![]() |
0 |
![]() |
erm.. i din really get your reply. However, i do solve the problem by just reinstall Perl on FreeBSD. Brian Wakem wrote: > janicehwang1325@yahoo.com wrote: > > > hi experts, > > > > my code is as simple as the follow. > > > > use Thread; > > $thr = new Thread \&sub1; # Spawn the thread > > > Try: > > $thr = Thread->new(\&sub1); > > > > $thr->detach; # Now we officially don't care any more > > > > sub sub1 { > > $a = 0; > > while (1) { > > $a++; > > print "\$a is $a\n"; > > sleep 1; > > } > > } > > > > > > however, when i compile it. The error occur stating "Undefined > > subroutine &threads::new called at sample_thread.pl line 2.". What is > > the reason? > > > -- > Brian Wakem > Email: http://homepage.ntlworld.com/b.wakem/myemail.png
![]() |
0 |
![]() |