Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl (http://www.velocityreviews.com/forums/f17-perl.html)
-   -   Qustion about ithreads join (http://www.velocityreviews.com/forums/t25356-qustion-about-ithreads-join.html)

Taewoon Kwon 09-10-2004 02:19 AM

Qustion about ithreads join
 
Nowadays, I learn about perl ithreads, reading perlthrtut perldoc.

I tested a sample code in that document

#---code start
use threads;

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

@ReturnData = $thr->join;
print "Thread returned @ReturnData";

sub sub1 { return "Fifty-six", "foo", 2; }
#---code end
and result of above code was printing '2', not 'Fifty-six foo 2'.

As far as I know it should print the 'Fifty-six foo 2'.
Could somebody explain the result?

Platform I tested the code was ActiveState Perl v5.8.4 for windows, and
perl v5.8.1 built in Mac Os X. Both showed the same result.

Joe Smith 09-15-2004 05:55 AM

Re: Qustion about ithreads join
 
Taewoon Kwon wrote:

> sub sub1 { return "Fifty-six", "foo", 2; }
> #---code end
> and result of above code was printing '2', not 'Fifty-six foo 2'.
>
> As far as I know it should print the 'Fifty-six foo 2'.
> Could somebody explain the result?


@array = sub1();
print "In list context, the result is @array\n";
$scalar = sub1();
print "In scalar context, the result is $scalar\n";

You should not expect them to return the same results.
-Joe


All times are GMT. The time now is 07:12 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.