[27952] in Perl-Users-Digest
Perl-Users Digest, Issue: 9316 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 19 18:05:51 2006
Date: Mon, 19 Jun 2006 15:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 19 Jun 2006 Volume: 10 Number: 9316
Today's topics:
forks from within a perl daemon process? <dszostek@gmail.com>
Re: installing Crypt::DES on ActiveState <sisyphus1@nomail.afraid.org>
Re: installing Crypt::DES on ActiveState <CSB001@gmail.com>
Re: installing Crypt::DES on ActiveState <Amaninder.Saini@gmail.com>
Re: installing Crypt::DES on ActiveState <Amaninder.Saini@gmail.com>
Re: noob asks: differences Activestate 5.8.x vs 5.6.x. (Phil)
Re: Printing hash in table format <hobosalesman@gmail.com>
question on "make test" <"v.niekerk at hccnet.nl">
Re: question on "make test" <glex_no-spam@qwest-spam-no.invalid>
Rpmdrake won't start :( <tomee@ZMIEN-tlen-NA-kadu.tlen.net>
Re: Rpmdrake won't start :( <glex_no-spam@qwest-spam-no.invalid>
Re: Rpmdrake won't start :( <glex_no-spam@qwest-spam-no.invalid>
Searching database with perl script servicio.hispano@gmail.com
Re: Searching database with perl script <no@email.com>
Re: Searching database with perl script <tsolorio3001@gmail.com>
two servers listening on same port ? sc_wizard29@hotmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Jun 2006 12:26:15 -0700
From: "Dave" <dszostek@gmail.com>
Subject: forks from within a perl daemon process?
Message-Id: <1150745175.776549.256080@r2g2000cwb.googlegroups.com>
Hi,
I have a program that I have been running via cron that I thought might
be better run by running it as a daemon. When I created some test
daemon programs they all worked. When I placed my program inside of the
while loop, I noticed that the daemon killed its self somehow. I then
figured out that it died just after it tried launching a new fork
process -- and when I commented this out it worked fine.
I made some sample code based on how I am doing this. I have it set to
print output to the screen. I have it below to not use threads. That
will let you see what it is supposed to do. Then, if you uncomment the
'use forks' statement, comment the line beginning with &browserbuilder,
and uncomment the line starting with ${$i}=threads you will see what it
does in a threads-based setup.
Can anyone provide any insight in to why this is not working and
perhaps give some advice for what I need to do?
Thanks,
~dave
PS> I would like to use forks instead of threads although I have them
both in the program for testing.
----------------------------
#!/usr/bin/perl
use POSIX qw(setsid);
&daemonize;
#use forks;
#use threads;
#uncomment one of two above modules to use that package for threading
use strict;
while(1) {
my (@urls,@urls2,$ib,$i);
$ib="a";
print "Started at " . `date` . "\n\n";
@urls=qw/1 2 3 4 5 6 7 8 9 10/;
foreach my $xurlid(@urls)
{
$i=$ib . $xurlid; #makes each thread object unique by adding
it's url id to '$ib' defined above
print "about to fork $xurlid thread\n";
#${$i}=threads->create(\&browserbuilder, $xurlid, 'dave');
#uncomment above to use thread-based setup
&browserbuilder($xurlid,'dave');
#uncomment above to use non-thread setup
push @urls2, $i; #used for checking thread status later
select(undef, undef, undef, 0.07); #sleep for 70 milliseconds
}
###########
# Go through each thread and wait for it to close so the program
doesn't exit early
#foreach my $url(@urls2)
# {
# @{$url} = ${$url}->join();
# print "$url returned: ${$url}[0]\n";
# }
###########
print "Ended at " . `date` . "\n\n";
sleep 10;
}
#end loop
sub browserbuilder
{
my $num=shift @_;
my $name=shift @_;
print "\n$name forked $num correctly\n\n";
return 0;
}
sub daemonize {
chdir '/' or die "Can't chdir to /: $!";
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
# open STDOUT, '>>/var/log/uu_info.log' or die "Can't write to
/dev/null: $!";
open STDERR, '>>/var/log/uu_errors.log' or die "Can't write to
/dev/null: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
umask 0;
}
------------------------------
Date: Tue, 20 Jun 2006 04:56:00 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: installing Crypt::DES on ActiveState
Message-Id: <4496f41c$0$2798$afc38c87@news.optusnet.com.au>
"Amaninder" <Amaninder.Saini@gmail.com> wrote in message
.
>
> I want to install Crypt::DES module ...
.
.
Try:
ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-DES.ppd
Cheers,
Rob
------------------------------
Date: 19 Jun 2006 12:07:15 -0700
From: "CsB" <CSB001@gmail.com>
Subject: Re: installing Crypt::DES on ActiveState
Message-Id: <1150744034.961382.70800@h76g2000cwa.googlegroups.com>
Did you try 'help repository' ???
Start PPM, 'ppm'
>From within PPM, type (all one line):
repository add Canada
http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58
Now, try:
search Crypt::DES
-or-
install Crypt::DES
Amaninder wrote:
> I tried to add new repository:
> rep add Canada
> http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58
> I got error again:
> 'rep' is not recognized as an internal or external command,
> operable program or batch file.
------------------------------
Date: 19 Jun 2006 12:11:26 -0700
From: "Amaninder" <Amaninder.Saini@gmail.com>
Subject: Re: installing Crypt::DES on ActiveState
Message-Id: <1150744286.457111.66120@p79g2000cwp.googlegroups.com>
Sisyphus wrote:
> "Amaninder" <Amaninder.Saini@gmail.com> wrote in message
> .
> >
> > I want to install Crypt::DES module ...
> .
> .
>
> Try:
> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-DES.ppd
>
> Cheers,
> Rob
Thanks for the reply Rob
It didnt work. Here is the result
Installing package 'http://theoryx5.uwinnipeg.ca/ppms/Crypt-DES.ppd'...
Error installing package
'http://theoryx5.uwinnipeg.ca/ppms/Crypt-DES.ppd': Read a PPD for
'http://theoryx5.uwinnipeg.ca/ppms/Crypt-DES.ppd', but it is not
intended for this build of Perl (MSWin32-x86-multi-thread)
Regards
Amaninder Saini
------------------------------
Date: 19 Jun 2006 13:08:16 -0700
From: "Amaninder" <Amaninder.Saini@gmail.com>
Subject: Re: installing Crypt::DES on ActiveState
Message-Id: <1150747696.872290.97170@h76g2000cwa.googlegroups.com>
Sisyphus wrote:
> "Amaninder" <Amaninder.Saini@gmail.com> wrote in message
> .
> >
> > I want to install Crypt::DES module ...
> .
> .
>
> Try:
> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-DES.ppd
>
> Cheers,
> Rob
Hi
I tried
ppm install http://theoryx5.uwinnipeg.ca/ppmpackages/Crypt-DES.ppd
instead of
> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-DES.ppd
and it worked. It works because "ppmpackages" are for build 6xx and
"ppms" are for 8xx. I have build 6xx for activeState so
ppm install http://theoryx5.uwinnipeg.ca/ppmpackages/Crypt-DES.ppd
worked for me.
Thanks everyone
Regards
Amaninder Saini
------------------------------
Date: Mon, 19 Jun 2006 15:13:33 -0400
From: boardhead62@hotmail.com (Phil)
Subject: Re: noob asks: differences Activestate 5.8.x vs 5.6.x. pros vs cons of each?
Message-Id: <boardhead62-1906061513330001@u87.n24.queensu.ca>
There is a bug in the memory handling of ActivePerl 5.8.x which
may cause EXTREME slowdowns when handling large blocks of memory.
One of my scripts was around 100x slower running on 5.8.x as
compared to the speed on 5.6.x. Other people have experienced
this problem as well.
In article <t7gc925ml27egde24omjoomj96gnk1eq6s@4ax.com>, noob@public.com wrote:
> For a Windows ME system, is there a reason not to use v5.8.8 and use
> 5.6.1 instead? Also for Win9x or WinXP.
------------------------------
Date: 19 Jun 2006 12:26:20 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: Re: Printing hash in table format
Message-Id: <1150745180.428647.216550@y41g2000cwy.googlegroups.com>
Deepu wrote:
> Once i have the 1st main table as input i read the table and store it
> in a hash with keys and values
> "TEST1-TEST2" => 1
> "TEST1-TEST3" => 0
Seems to me that's a real bad way to store your data. Now you have to
split a string into two fields in order to do anything useful.
STATES TEST1 TEST2 TEST3
TEST1 2 1 3
TEST2 1 0 0
TEST3 4 6 3
my $index = {
'STATES' => 0,
'TEST1' => 1,
'TEST2' => 2,
'TEST3' => 3,
};
my $table = [
[ "TEST1", 2, 1, 3 ],
[ "TEST2", 1, 0, 0 ],
[ "TEST3", 4, 6, 3 ],
];
#prints TEST1 field for second entry (1)
print $table->[1][$index->{"TEST1"}];
#prints the table
foreach my $entry (@$table) {
print join(" ", @$entry)."\n";
}
------------------------------
Date: Mon, 19 Jun 2006 21:31:12 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: question on "make test"
Message-Id: <4496fb82$0$8254$e4fe514c@dreader14.news.xs4all.nl>
Hi,
After a successful "make", "make test" goes wrong with this:
> PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
> t/00base.............install_driver(mysql) failed: Can't load '/root/.cpan/build/DBD-mysql-3.0006/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: /root/.cpan/build/DBD-mysql-3.0006/blib/arch/auto/DBD/mysql/mysql.so: cannot restore segment prot after reloc: Permission denied at /usr/lib/perl5/5.8.8/i386-linux-thread-multi/DynaLoader.pm line 230.
> at (eval 3) line 3
> Compilation failed in require at (eval 3) line 3.
> Perhaps a required shared library or dll isn't installed where expected
> at t/00base.t line 38
> t/00base.............dubious
> Test returned status 2 (wstat 512, 0x200)
> DIED. FAILED tests 4-5
> Failed 2/5 tests, 60.00% okay
More failures follow after this one. I did "make install" after this,
but that goes wrong. What is the best thing to do?
Thanks,
Huub
------------------------------
Date: Mon, 19 Jun 2006 15:52:33 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: question on "make test"
Message-Id: <hdElg.9$oX2.2030@news.uswest.net>
Huub wrote:
> Hi,
>
> After a successful "make", "make test" goes wrong with this:
A successful make of what?
>> /root/.cpan/build/DBD-mysql-3.0006/blib/arch/auto/DBD/mysql/mysql.so:
>> cannot restore segment prot after reloc: Permission denied at
> More failures follow after this one. I did "make install" after this,
> but that goes wrong. What is the best thing to do?
YAATCBFUSE (Yet Another Answer That Could Be Found Using a Search Engine)
I entered "cannot restore segment prot after reloc", in my favorite
search engine, and found a bunch of helpful sites. Nothing to do with
perl, everything to do with your OS.
------------------------------
Date: Mon, 19 Jun 2006 21:00:41 +0200
From: Tomek Jarzynka <tomee@ZMIEN-tlen-NA-kadu.tlen.net>
Subject: Rpmdrake won't start :(
Message-Id: <1529027.14lRrY2Ckc@arista.4mind.pl>
Hi,
after trying to install some software, rpmdrake, which is written in perl,
stopped functioning.
I get the following in the console:
[root@aereo ~/rpm]# rpmdrake
can not find function c::bind_textdomain_codeset
c::AUTOLOAD() called from /usr/lib/perl5/vendor_perl/5.8.7/rpmdrake.pm:91
(eval)() called from /usr/sbin/rpmdrake:50
main::BEGIN() called from /usr/lib/perl5/vendor_perl/5.8.7/rpmdrake.pm:0
(eval)() called from /usr/lib/perl5/vendor_perl/5.8.7/rpmdrake.pm:0
Compilation failed in require at /usr/sbin/rpmdrake line 50.
BEGIN failed--compilation aborted at /usr/sbin/rpmdrake line 50.
What can that mean? Where to look? I'm confused :|
I am a total perl idiot.
--
tomasz k. jarzynka / 601 706 601 / tomee(a-t)kadu(d-o-t)net
"Utrzymuję, że oboje jesteśmy ateistami. Ja tylko nie wierzę w jednego
więcej boga niż ty. Gdy zrozumiesz, czemu nie wierzysz we wszystkich
pozostałych, zrozumiesz czemu ja nie wierzę w twojego. (Stephen Roberts)"
------------------------------
Date: Mon, 19 Jun 2006 14:09:22 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Rpmdrake won't start :(
Message-Id: <yIClg.5$oX2.1433@news.uswest.net>
Tomek Jarzynka wrote:
> Hi,
>
> after trying to install some software, rpmdrake, which is written in perl,
> stopped functioning.
> I get the following in the console:
>
> [root@aereo ~/rpm]# rpmdrake
> can not find function c::bind_textdomain_codeset
> c::AUTOLOAD() called from /usr/lib/perl5/vendor_perl/5.8.7/rpmdrake.pm:91
> (eval)() called from /usr/sbin/rpmdrake:50
> main::BEGIN() called from /usr/lib/perl5/vendor_perl/5.8.7/rpmdrake.pm:0
> (eval)() called from /usr/lib/perl5/vendor_perl/5.8.7/rpmdrake.pm:0
> Compilation failed in require at /usr/sbin/rpmdrake line 50.
> BEGIN failed--compilation aborted at /usr/sbin/rpmdrake line 50.
>
> What can that mean? Where to look? I'm confused :|
> I am a total perl idiot.
You don't have to know perl to use a search engine. Simply entering
"rpmdrake.pm: in Google showed the following link, which seems to be
quite similar.
http://www.linuxquestions.org/questions/showthread.php?p=2226828
------------------------------
Date: Mon, 19 Jun 2006 15:54:09 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Rpmdrake won't start :(
Message-Id: <MeElg.10$oX2.2023@news.uswest.net>
J. Gleixner wrote:
> You don't have to know perl to use a search engine. Simply entering
> "rpmdrake.pm: in Google showed the following link, which seems to be
^"
> quite similar.
>
> http://www.linuxquestions.org/questions/showthread.php?p=2226828
------------------------------
Date: 19 Jun 2006 11:17:26 -0700
From: servicio.hispano@gmail.com
Subject: Searching database with perl script
Message-Id: <1150741046.693231.165830@i40g2000cwc.googlegroups.com>
I'm new at this and can't get this to work. I have this form where I'm
trying to search by last name but the page where the results should be
come up blank. I know I must be missing something simple. I apologize
if this is the wrong place to post this. Here's my code:
sub name_search(){
print $q->header();
print $q->start_html();
# if($submit) {
my $dbh = DBI->connect("DBI:mysql:policy",
"*******", "*******");
if($submit) {
my $sql = "SELECT polID, lname1, fname FROM
customers where lname1 = $lname1"; #trying to match the value in the
textfield
my $sth = $dbh->prepare($sql);
while(my($p, $l, $f) = $sth->fetchrow_array()){
print "<table>\n";
print
"<tr><td>$p</td><td>$l</td><td>$f</td></tr>\n";
print "</table>\n";
}
}else{
print $q->start_form();
print $q->hidden('op', 'name_search');
print $q->hidden('lname1', $lname1);
print "<table>";
print "<tr><td>Last Name</td><td>" .
$q->textfield('lname1', '$lname1', '', '') . $q->submit('submit',
'Search');
print "</td></tr>";
print "</table>";
print $q->end_form();
print $q->end_html();
#$sth->finish();
}
$dbh->disconnect();
}
The textbox and submit button shows up fine. I don't get any errors. I
just don't get anything in the results. It just goes to a blank page. I
know I've gotten this to work before but because of my job I haven't
had the chance to practice. What I learned I have forgotten.
Thanks for any help.
------------------------------
Date: Mon, 19 Jun 2006 19:54:19 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Searching database with perl script
Message-Id: <4foa6rF1jggfvU1@individual.net>
servicio.hispano@gmail.com wrote:
> I'm new at this and can't get this to work. I have this form where I'm
> trying to search by last name but the page where the results should be
> come up blank. I know I must be missing something simple. I apologize
> if this is the wrong place to post this. Here's my code:
>
> sub name_search(){
> print $q->header();
> print $q->start_html();
> # if($submit) {
>
>
> my $dbh = DBI->connect("DBI:mysql:policy",
> "*******", "*******");
> if($submit) {
>
> my $sql = "SELECT polID, lname1, fname FROM
> customers where lname1 = $lname1"; #trying to match the value in the
> textfield
> my $sth = $dbh->prepare($sql);
> while(my($p, $l, $f) = $sth->fetchrow_array()){
You can't fetch without execute.
$sth->execute();
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: 19 Jun 2006 14:00:48 -0700
From: "tonya solorio" <tsolorio3001@gmail.com>
Subject: Re: Searching database with perl script
Message-Id: <1150750848.043941.54420@c74g2000cwc.googlegroups.com>
Brian Wakem wrote:
> servicio.hispano@gmail.com wrote:
>
> > I'm new at this and can't get this to work. I have this form where I'm
> > trying to search by last name but the page where the results should be
> > come up blank. I know I must be missing something simple. I apologize
> > if this is the wrong place to post this. Here's my code:
> >
> > sub name_search(){
> > print $q->header();
> > print $q->start_html();
> > # if($submit) {
> >
> >
> > my $dbh = DBI->connect("DBI:mysql:policy",
> > "*******", "*******");
> > if($submit) {
> >
> > my $sql = "SELECT polID, lname1, fname FROM
> > customers where lname1 = $lname1"; #trying to match the value in the
> > textfield
> > my $sth = $dbh->prepare($sql);
> > while(my($p, $l, $f) = $sth->fetchrow_array()){
>
>
> You can't fetch without execute.
>
> $sth->execute();
Thank you!! :)
Now I feel dumb. :-|
See, I knew it was simple.
>
>
>
> --
> Brian Wakem
> Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: 19 Jun 2006 13:17:56 -0700
From: sc_wizard29@hotmail.com
Subject: two servers listening on same port ?
Message-Id: <1150748276.735336.108720@p79g2000cwp.googlegroups.com>
hi everyone,
This ones makes me scratch my head : I'm using the following script on
Windows and it looks like I can run two instances of it
simultaneously...which means that I have 2 servers listening on the
same port.
#!/usr/bin/perl -w
use strict;
use Socket;
my $port = 8080;
my $proto = getprotobyname('tcp');
socket(Server, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) || die
"setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY)) || die "bind: $!";
listen(Server,SOMAXCONN) || die "listen: $!";
print "Server : server started on port $port\n";
while(1) {}
I was expecting an error like "port already in use". Am I doing
something wrong ?
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9316
***************************************