Thanks for the comments.
use threads;
Somehow, I am not able to pass parameters to sub routines using threads->create.
Below are the sample code and errors.
Better.pm
package Better;
sub saveBetter {
my ($sbn, $cost, $ur) = @_;
print "sbn: $sbn\n";
print "cost: $cost\n";
print "url: $url\n";
return;
}
1;
test.pl
#!/usr/bin/perl -w
use strict;
use warnings;
use threads;
use Better;
my $sbn = "123489876";
my $lee = "12.89";
my $abc = "abcde";
my @ParamList = ($sbn, $lee, $abc);
my $thr = threads->create(Better::saveBetter, @ParamList);
$thr->join();
./test.pl
Use of uninitialized value in concatenation (.) or string at Better.pm line 6.
sbn:
Use of uninitialized value in concatenation (.) or string at Better.pm line 7.
cost:
Use of uninitialized value in concatenation (.) or string at Better.pm line 8.
url:
Thread 1 terminated abnormally: Undefined subroutine &main::123489876 called at ./test.pl line 14.
Changed code to
#!/usr/bin/perl -w
use strict;
use warnings;
use threads;
use Better;
my $sbn = "123489876";
my $lee = "12.89";
my $abc = "abcde";
my $thr = threads->create(Better::saveBetter, $sbn, $lee, $abc);
$thr->join();
Still got same error.
Any idea?
Some output of perl -V
perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=linux, osvers=2.6.18-128.1.10.el5, archname=x86_64-linux-thread-multi
uname='linux ls20-bc2-13.build.redhat.com 2.6.18-128.1.10.el5 #1 smp wed apr 29 13:53:08 edt 2009 x86_64 x86_64 x86_64 gnulinux '
usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.