in reply to Threads Calling Subroutine from different PM File

In addition to the previous answer, you can wrap it into an anonymous subroutine, like this:

my $thr = threads->new( sub { MyModule::Execute($arg1, $arg2) } );

(but do check that your code does not change the values of $arg1 and $arg2 after that. With proper scoping, that is not hard to do.)

Replies are listed 'Best First'.
Re^2: Threads Calling Subroutine from different PM File
by BrowserUk (Patriarch) on Nov 26, 2012 at 17:46 UTC

    There is no virtue in doing that. It would be completely pointless.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

      Yes, in this very case, but the times you can't pass arguments to the subroutine, it is invaluable.

        in this very case,

        And any case where you are passing a code reference to the threads module.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong