arunsub has asked for the wisdom of the Perl Monks concerning the following question:

I am getting compilation errors with the following code.
******************************************************** #script to ftp AI executables to different machines<br> # Requirements Perl 5.8 or higher to support Thread use Thread; $thread0= Thread->new<br>(sendftp, "#HOST","#USER","#PASSWORD"); $_->join foreach ($thread0); sendftp("#Host","#User","#Password"); sub sendftp { $FileList="installServer.jar "; $Temp1 = Thread->self->tid(); exec `sendftp.sh $_[0] $_[1] $_[2] `; exit(0); }
Error :-
This Perl has neither ithreads nor 5005threads
at /usr/local/lib/perl5/5.8.0/Car p.pm line 335 BEGIN failed--compilation aborted at /usr/local/lib/perl5/5.8.0/Thread.pm line 3 35. Compilation failed in require at sendftp.pl line 4. BEGIN failed--compilation aborted at sendftp.pl line 4.
Question
Is it a problem with the Perl Version that I am using, I am having Perl 5.8.0. The same code works perfectly in windows. Thanks.

Edit by castaway - added code tags

Replies are listed 'Best First'.
Re: Thread Error
by Zaxo (Archbishop) on Dec 17, 2003 at 06:29 UTC
    This Perl has neither ithreads nor 5005threads

    That is one problem - your perl is not compiled to support threaded code. Get or build one that does.

    The other problem. which isn't affecting you yet, is that you specify 5.8, but then use Thread;. That is the old 5.005 thread module. Perl 5.8 does ithreads by default, so use threads; is the proper invocation.

    After Compline,
    Zaxo

      Not quite.. if you look at the documentation ('man Thread') in the most recent versions (5.8.0+), you'll see that 'use Thread' is now a frontend to either 5.005 threads, or ithreads, making the invocation valid for whichever perl.

      (Though of course when starting something new it's probably better to start off with the new interface.)

      C.

      Thanx for the quick response, I am new to Perl in Unix, It would be a real help if u can provide some more details on how to implement threads in Perl on Unix. Note :- The same syntax works fine when I run the code in Windows (Perl 5.8.0).
        It runs fine on Windows, because the Windows perls come with threads built-in (cos Windows doesnt have forking, or some such reason.)

        Anyway, you'll either need to build a new perl on your system, which if you're a newbie to Unix probably isnt such a good idea, or you'll need to install a package (depending on which unix/linux/whatever you are using) containing a threaded perl.

        (Theres no way to just 'add' thread support to the perl you have installed, it needs to be compiled that way.)

        If you do want to compile your own, go to perl-5.8.2, grab the source, and read the README and INSTALL docs..

        You'll probably benefit from reading 'man Thread', which explains this.

        C.