Qustion about ithreads join

Discussion in 'Perl' started by Taewoon Kwon, Sep 10, 2004.

  1. Taewoon Kwon

    Taewoon Kwon Guest

    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.
     
    Taewoon Kwon, Sep 10, 2004
    #1
    1. Advertising

  2. Taewoon Kwon

    Joe Smith Guest

    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
     
    Joe Smith, Sep 15, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Morel

    Is the ithreads implementation safe?

    David Morel, Sep 13, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    110
    David Morel
    Sep 13, 2003
  2. Walter Roberson

    Knight's tour in perl ithreads

    Walter Roberson, Feb 2, 2004, in forum: Perl Misc
    Replies:
    0
    Views:
    140
    Walter Roberson
    Feb 2, 2004
  3. Walter Roberson

    ithreads at runtime?

    Walter Roberson, Feb 3, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    105
    Walter Roberson
    Feb 4, 2004
  4. Thomas Jahns

    ithreads + signals on modern Unices

    Thomas Jahns, Feb 7, 2005, in forum: Perl Misc
    Replies:
    4
    Views:
    128
  5. Micha³ Lesiak (bler)

    ithreads & memory

    Micha³ Lesiak (bler), Jul 18, 2005, in forum: Perl Misc
    Replies:
    10
    Views:
    189
Loading...

Share This Page