How can I make this Perl Script run Multi-threaded?
I have to submit a class project for a perl script that run in a multithread and validates MX record against a list. I think I have the script ready but I just don't know how to implement multithreading to make it run, for example, in 50 threads. Kindly examine script below and help. SO basically, what I want it to do is to make the script run in a multithreaded way to speed it up and make it complete faster.
Your help is very much appreciated.
Edit: solved
multithreading perl
add a comment |
I have to submit a class project for a perl script that run in a multithread and validates MX record against a list. I think I have the script ready but I just don't know how to implement multithreading to make it run, for example, in 50 threads. Kindly examine script below and help. SO basically, what I want it to do is to make the script run in a multithreaded way to speed it up and make it complete faster.
Your help is very much appreciated.
Edit: solved
multithreading perl
3
Instead of reaching for threads, I think it's better to use the parallel API ofNet::DNS
as shown in the examples, metacpan.org/source/NLNETLABS/Net-DNS-1.18/demo/mresolv etc.
– Corion
Nov 14 '18 at 11:55
I don't see you using any threads in your code, could you post the specific part with which you have an issue?
– Adonis
Nov 14 '18 at 11:56
@Adonis I don't really have an issue with the code itself. Running the code works BUT in just one instance. So if I have a database of say 200,000 entries, you can imagine how long it would take to go through it? If I am able to make the code run as a multi thread, say for example, 10 threads, then it would shorten the time to one-tenth. The issue is how do I add multithread. I went over some multithreading manuals and documents but it's so complex for me. Thanks
– user10651610
Nov 14 '18 at 18:12
Stackoverflow deals mainly with specific coding issues, not with the creation of new features...
– Adonis
Nov 15 '18 at 10:10
add a comment |
I have to submit a class project for a perl script that run in a multithread and validates MX record against a list. I think I have the script ready but I just don't know how to implement multithreading to make it run, for example, in 50 threads. Kindly examine script below and help. SO basically, what I want it to do is to make the script run in a multithreaded way to speed it up and make it complete faster.
Your help is very much appreciated.
Edit: solved
multithreading perl
I have to submit a class project for a perl script that run in a multithread and validates MX record against a list. I think I have the script ready but I just don't know how to implement multithreading to make it run, for example, in 50 threads. Kindly examine script below and help. SO basically, what I want it to do is to make the script run in a multithreaded way to speed it up and make it complete faster.
Your help is very much appreciated.
Edit: solved
multithreading perl
multithreading perl
edited Nov 30 '18 at 20:04
asked Nov 14 '18 at 11:26
user10651610
3
Instead of reaching for threads, I think it's better to use the parallel API ofNet::DNS
as shown in the examples, metacpan.org/source/NLNETLABS/Net-DNS-1.18/demo/mresolv etc.
– Corion
Nov 14 '18 at 11:55
I don't see you using any threads in your code, could you post the specific part with which you have an issue?
– Adonis
Nov 14 '18 at 11:56
@Adonis I don't really have an issue with the code itself. Running the code works BUT in just one instance. So if I have a database of say 200,000 entries, you can imagine how long it would take to go through it? If I am able to make the code run as a multi thread, say for example, 10 threads, then it would shorten the time to one-tenth. The issue is how do I add multithread. I went over some multithreading manuals and documents but it's so complex for me. Thanks
– user10651610
Nov 14 '18 at 18:12
Stackoverflow deals mainly with specific coding issues, not with the creation of new features...
– Adonis
Nov 15 '18 at 10:10
add a comment |
3
Instead of reaching for threads, I think it's better to use the parallel API ofNet::DNS
as shown in the examples, metacpan.org/source/NLNETLABS/Net-DNS-1.18/demo/mresolv etc.
– Corion
Nov 14 '18 at 11:55
I don't see you using any threads in your code, could you post the specific part with which you have an issue?
– Adonis
Nov 14 '18 at 11:56
@Adonis I don't really have an issue with the code itself. Running the code works BUT in just one instance. So if I have a database of say 200,000 entries, you can imagine how long it would take to go through it? If I am able to make the code run as a multi thread, say for example, 10 threads, then it would shorten the time to one-tenth. The issue is how do I add multithread. I went over some multithreading manuals and documents but it's so complex for me. Thanks
– user10651610
Nov 14 '18 at 18:12
Stackoverflow deals mainly with specific coding issues, not with the creation of new features...
– Adonis
Nov 15 '18 at 10:10
3
3
Instead of reaching for threads, I think it's better to use the parallel API of
Net::DNS
as shown in the examples, metacpan.org/source/NLNETLABS/Net-DNS-1.18/demo/mresolv etc.– Corion
Nov 14 '18 at 11:55
Instead of reaching for threads, I think it's better to use the parallel API of
Net::DNS
as shown in the examples, metacpan.org/source/NLNETLABS/Net-DNS-1.18/demo/mresolv etc.– Corion
Nov 14 '18 at 11:55
I don't see you using any threads in your code, could you post the specific part with which you have an issue?
– Adonis
Nov 14 '18 at 11:56
I don't see you using any threads in your code, could you post the specific part with which you have an issue?
– Adonis
Nov 14 '18 at 11:56
@Adonis I don't really have an issue with the code itself. Running the code works BUT in just one instance. So if I have a database of say 200,000 entries, you can imagine how long it would take to go through it? If I am able to make the code run as a multi thread, say for example, 10 threads, then it would shorten the time to one-tenth. The issue is how do I add multithread. I went over some multithreading manuals and documents but it's so complex for me. Thanks
– user10651610
Nov 14 '18 at 18:12
@Adonis I don't really have an issue with the code itself. Running the code works BUT in just one instance. So if I have a database of say 200,000 entries, you can imagine how long it would take to go through it? If I am able to make the code run as a multi thread, say for example, 10 threads, then it would shorten the time to one-tenth. The issue is how do I add multithread. I went over some multithreading manuals and documents but it's so complex for me. Thanks
– user10651610
Nov 14 '18 at 18:12
Stackoverflow deals mainly with specific coding issues, not with the creation of new features...
– Adonis
Nov 15 '18 at 10:10
Stackoverflow deals mainly with specific coding issues, not with the creation of new features...
– Adonis
Nov 15 '18 at 10:10
add a comment |
1 Answer
1
active
oldest
votes
When I get home, I'll write a better manual. Including code excerpts
- Step 1: Create a sequence with all important calls as a separate function
- Step 2: Use the function from step 1 to create the individual threads and specialize this function with the individual parameters
- Step 3: After the sequence is finish detach the thread.
Maybe do Step 2 as a Loop/Daemon
Here you can read something about threads and how do you use them in your code.
mathematik.uni-ulm.de - English Tutorial Modul threads
The Perldoc have a good example too:
perldoc - threads
Thank you for the reference materials. I will go through while I await your manual.
– user10651610
Nov 14 '18 at 18:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299123%2fhow-can-i-make-this-perl-script-run-multi-threaded%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When I get home, I'll write a better manual. Including code excerpts
- Step 1: Create a sequence with all important calls as a separate function
- Step 2: Use the function from step 1 to create the individual threads and specialize this function with the individual parameters
- Step 3: After the sequence is finish detach the thread.
Maybe do Step 2 as a Loop/Daemon
Here you can read something about threads and how do you use them in your code.
mathematik.uni-ulm.de - English Tutorial Modul threads
The Perldoc have a good example too:
perldoc - threads
Thank you for the reference materials. I will go through while I await your manual.
– user10651610
Nov 14 '18 at 18:15
add a comment |
When I get home, I'll write a better manual. Including code excerpts
- Step 1: Create a sequence with all important calls as a separate function
- Step 2: Use the function from step 1 to create the individual threads and specialize this function with the individual parameters
- Step 3: After the sequence is finish detach the thread.
Maybe do Step 2 as a Loop/Daemon
Here you can read something about threads and how do you use them in your code.
mathematik.uni-ulm.de - English Tutorial Modul threads
The Perldoc have a good example too:
perldoc - threads
Thank you for the reference materials. I will go through while I await your manual.
– user10651610
Nov 14 '18 at 18:15
add a comment |
When I get home, I'll write a better manual. Including code excerpts
- Step 1: Create a sequence with all important calls as a separate function
- Step 2: Use the function from step 1 to create the individual threads and specialize this function with the individual parameters
- Step 3: After the sequence is finish detach the thread.
Maybe do Step 2 as a Loop/Daemon
Here you can read something about threads and how do you use them in your code.
mathematik.uni-ulm.de - English Tutorial Modul threads
The Perldoc have a good example too:
perldoc - threads
When I get home, I'll write a better manual. Including code excerpts
- Step 1: Create a sequence with all important calls as a separate function
- Step 2: Use the function from step 1 to create the individual threads and specialize this function with the individual parameters
- Step 3: After the sequence is finish detach the thread.
Maybe do Step 2 as a Loop/Daemon
Here you can read something about threads and how do you use them in your code.
mathematik.uni-ulm.de - English Tutorial Modul threads
The Perldoc have a good example too:
perldoc - threads
answered Nov 14 '18 at 15:13
Darius DDarius D
412
412
Thank you for the reference materials. I will go through while I await your manual.
– user10651610
Nov 14 '18 at 18:15
add a comment |
Thank you for the reference materials. I will go through while I await your manual.
– user10651610
Nov 14 '18 at 18:15
Thank you for the reference materials. I will go through while I await your manual.
– user10651610
Nov 14 '18 at 18:15
Thank you for the reference materials. I will go through while I await your manual.
– user10651610
Nov 14 '18 at 18:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299123%2fhow-can-i-make-this-perl-script-run-multi-threaded%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Instead of reaching for threads, I think it's better to use the parallel API of
Net::DNS
as shown in the examples, metacpan.org/source/NLNETLABS/Net-DNS-1.18/demo/mresolv etc.– Corion
Nov 14 '18 at 11:55
I don't see you using any threads in your code, could you post the specific part with which you have an issue?
– Adonis
Nov 14 '18 at 11:56
@Adonis I don't really have an issue with the code itself. Running the code works BUT in just one instance. So if I have a database of say 200,000 entries, you can imagine how long it would take to go through it? If I am able to make the code run as a multi thread, say for example, 10 threads, then it would shorten the time to one-tenth. The issue is how do I add multithread. I went over some multithreading manuals and documents but it's so complex for me. Thanks
– user10651610
Nov 14 '18 at 18:12
Stackoverflow deals mainly with specific coding issues, not with the creation of new features...
– Adonis
Nov 15 '18 at 10:10