Thread threads => Grundwissen (50 answers)
Opened by RPerl at 2007-01-21 18:07

RPerl
 2007-01-24 18:47
#73458 #73458
User since
2006-11-26
384 Artikel
BenutzerIn

user image
hööööööööö?
Ich kriege nun krasse Fehler. habe zwischenzeitlich auf activeperl 5.6.1 downgraded.
?????
Nun kriege ich mal Fehler mal nicht?!

Fehler 1:
Quote
Can't undef active subroutine during global destruction.


Script 1:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/perl
use threads;


$thr = threads->new(\&sub1);

sub sub1() 
{
}

my @ReturnData = $thr->join;
print @ReturnData;


Fehler 2: Can't locate object method "new" via package "Thread" (perhaps you forgot to load "Thread"?)
Script 2:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl 

use Tie::File;
use threads;

my $file = 'german.txt';
my (@array_1, @array_2);
tie my @array,'Tie::File',$file or die $!;

my $index = int(scalar(@array) / 2);

@array_1 = @array[0..$index];
@array_2 = @array[$index+1..$#array];

untie @array;


sub abfrage{
   my ($arref) = @_;
   for my $element(@$arref){
       print $element;
   }
}

my $thr = new Thread \&abfrage, @array_1;
my $thr = new Thread \&abfrage, @array_2;
\n\n

<!--EDIT|RPerl|1169657448-->

View full thread threads => Grundwissen