[9689] in Perl-Users-Digest
Perl-Users Digest, Issue: 3283 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 29 07:07:40 1998
Date: Wed, 29 Jul 98 04:00:28 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 29 Jul 1998 Volume: 8 Number: 3283
Today's topics:
Re: Can't figure out how to remove newlines (Abigail)
forked children won't terminate dwiesel@my-dejanews.com
Re: forked children won't terminate <qdtcall@esb.ericsson.se>
Re: getting the binary represenation of a number (Abigail)
launching programs in perl scripts <buga@ipm.lviv.ua>
Re: Loop Problem dave@mag-sol.com
Re: Nead a Redir Script, Please <minich@globalnet.co.uk>
Re: Net::Telnet -like module without telnet (Miguel Cruz)
Newbie: extracting fields greggman@my-dejanews.com
Re: Newbie: extracting fields <pawelg@obop.com.pl>
Re: Perl5.005: any good Thread::kill workaround ideas? (Ilya Zakharevich)
perl5.005_01 with threads on HP-UX <boschini@cilea.it>
Test failures compiling perl5.005 (Mystic Zen Biker Twigboy)
Re: Try perl on Ms Dos <jwb79@mail.idt.net>
Re: WANTED: Perl Autoreponder - Any Takers? <aperrin@mcmahon.qal.berkeley.edu>
Why doesn't 'man perlipc' domain sample code work? (Miguel Cruz)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Jul 1998 07:37:57 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Can't figure out how to remove newlines
Message-Id: <6pmjgl$1u$2@client3.news.psi.net>
Terrence E. S. Thompson (thompson@m-net.arbornet.org) wrote on MDCCXCIII
September MCMXCIII in <URL: news:35BE94CA.3621E77A@m-net.arbornet.org>:
++ Hi, I've got a problem that is just driving me crazy. I've looked
++ in the manual and the faq, but I'm just not getting it. How exactly
++ do I remove a newline from the end of a string?
{local $/ = "\n"; chomp $string;}
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Wed, 29 Jul 1998 06:54:30 GMT
From: dwiesel@my-dejanews.com
Subject: forked children won't terminate
Message-Id: <6pmgv6$gih$1@nnrp1.dejanews.com>
Ok, so now when I run the program I get the following output:
447 foked process 448 (started: 0)
447 foked process 449 (started: 1)
447 foked process 450 (started: 2)
447 foked process 451 (started: 3)
447 foked process 452 (started: 4)
Child stuff by 448
Child stuff by 449
Child stuff by 450
Child stuff by 451
Child stuff by 452
447 reaped a child (finished: 1)
447 reaped a child (finished: 2)
<neverending loop>
Why won't the other children terminate?
// Daniel
----some code----
#!/usr/local/bin/perl -w
use strict;
my $number_of_forks = 5;
my $started_forks = 0;
my $finished_forks = 0;
$SIG {CHLD} = sub { wait;
$finished_forks ++;
warn "$$ reaped a child (finished: $finished_forks)\n";
};
while ($started_forks < $number_of_forks) {
my $pid = fork;
# Parent
if ($pid) {
warn "$$ forked process $pid (started: $started_forks)\n";
$started_forks ++;
}
else {
# Child
if (defined $pid) {
warn "Child stuff by $$\n";
}
# Failure
else {
warn "Fork by $$ failed\n";
}
exit;
}
}
while ($finished_forks != $number_of_forks) {sleep 1;}
warn "$$: Terminating\n";
----some code----
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 29 Jul 1998 09:22:48 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: forked children won't terminate
Message-Id: <isk94xce9j.fsf@godzilla.kiere.ericsson.se>
dwiesel@my-dejanews.com writes:
> Why won't the other children terminate?
They do (check with ps). What's happening is that some SIGCHLDs are
arriving while you're still processing the previous one, and therefore
dropped on the floor. Insert some sleeps of different lengths in the
children (so that they don't all die at the same time) and your
program will behave as you expect it to.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: 29 Jul 1998 07:35:14 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: getting the binary represenation of a number
Message-Id: <6pmjbi$1u$1@client3.news.psi.net>
Lloyd Zusman (ljz@asfast.com) wrote on MDCCXCIII September MCMXCIII in
<URL: news:lthg011bys.fsf@asfast.com>:
++
++ Yes. And also, in the old days, many CPU's tended to perform bit
++ shifts much faster than multiplications or divisions (and most still
++ do, to the best of my knowledge). Therefore, to save time on the much
++ slower CPU's of yesteryear, people would sometimes use these bit
++ shifts as a speedier method of multiplying or dividing by powers of
++ two ... especially when programming in certain languages which tended
++ to operate "close to the hardware".
Good compiler will choose the optimal machine code, regardless whether
you use << 1 or * 2.
Abigail
--
perl -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
print chr 0x$& and q
qq}*excess********}'
------------------------------
Date: Wed, 29 Jul 1998 10:31:07 +0200
From: "Yaroslav Buga" <buga@ipm.lviv.ua>
Subject: launching programs in perl scripts
Message-Id: <6pmiu4$9ft$1@MU.icmp.lviv.ua>
Somebody, tell me please how to launch program (for example ping) in perl
script.
Please e-mail me to buga@ipm.lviv.ua
Thank You,
Slava.
------------------------------
Date: Wed, 29 Jul 1998 07:58:13 GMT
From: dave@mag-sol.com
Subject: Re: Loop Problem
Message-Id: <6pmkmk$nub$1@nnrp1.dejanews.com>
In article <MPG.102782a319a1f4c989797@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:
> [Posted to comp.lang.perl.misc and copy mailed.]
>
> In article <6pk09j$3qa$1@nnrp1.dejanews.com> on Tue, 28 Jul 1998 07:57:40
> GMT, dave@mag-sol.com <dave@mag-sol.com> says...
> ...
> > if (($line =~ /$nameitem/) &&
> > ($line =~ /$familyitem/))
> >
> > which you expect to fail if $nameitem and $familyitem don't have data in
them.
> > In this case they will effectively contain an empty string and an empty
string
> > will match whatever you have in $line.
>
> No it won't. It will match whatever the previous successful match did.
> Here is a simple test:
>
> #!/usr/local/bin/perl -w
> use strict;
>
> my $foo = '';
> $_ = 'abcd';
> /bc/;
> /$foo/ and print "$_\n"; # prints abcd
> $_ = 'efgh';
> /$foo/ and print "$_\n"; # doesn't print -- no match against 'bc'
Yes it will, here's a simpler script to illustrate.
# Match an empty regular expression with any string
if ('random string' =~ //)
{
print "Match\n";
}
else
{
print "No match\n";
}
Dave...
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 29 Jul 1998 10:57:02 +0100
From: "Martin" <minich@globalnet.co.uk>
Subject: Re: Nead a Redir Script, Please
Message-Id: <6pmrm7$mnr$1@heliodor.xara.net>
Hi!
>I've got a txt file were I can put this information :
>
>struture.txt
>
>-------------------------------------------------
>home=http://myserver.com/
>links=http://myserver.com/links/
>files=http://myserver.com/files/
>-------------------------------------------------
>
>and then a script that will work with this tag:
>
><a href="http://myserver/cgi-bin/redir.cgi?id=home">Home Page</a>
><a href="http://myserver/cgi-bin/redir.cgi?id=links">Links Page</a>
><a href="http://myserver/cgi-bin/redir.cgi=id=files">Files Page</a>
>
>the script will read the txt file and redirect the browser to the
>respective page.
>If someone put http://myserver/cgi-bin/redir.cgi in the browser, this
>will redirect automaticaly to the Home Page ( http://myserver ).
>I nead this script to organize the files and for easy link others
>pages.
OK, so that's not really a major project! <g>
#! Shebang
$file = "cgi-bin/structure.txt";
open (INF,$file) or die "open $filename: $!";
@indata = <INF>;
close(INF);
$url = "";
$id = $ENV{QUERY_STRING};
$id =~ s/id=//g;
foreach $_ (@indata) {
if ( /$id(.*?)=/i && $1 eq "") {
$url = $';
}
}
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><frameset cols 100%><frame src=$url></head></html>
EndOfHTML
;
Exit;
THAT MIGHT WORK, I HAVEN'T TESTED IT YET.
>This script is for hide the forlder were I4m going to put some files
>too, so I don4t want the real address to apear in the browser when
>someone links to the files folder.
It won't appear in the browser window but it will appear in the source
code if the user decides to view it. What you're asking is extremely
actually expensive and I haven't got a clue how to do it!
>I would like, if possible, when someone links to a file, they only see
>something like this :
>
>http://myserver/cgi-bin/redir.cgi?id=filename
>
>Can anyone help me ??
That's what they (should) see!
Martin
PS> Put the structure.txt file in your cgi-bin directory with
this cgi.
PPS> Sort your e-mail address out. IT BELONGS TO SOMEONE
ELSE!
------------------------------
Date: 29 Jul 1998 08:36:43 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Re: Net::Telnet -like module without telnet
Message-Id: <6pmmur$mod$1@news.ycc.yale.edu>
Antti-Jussi Korjonen <Antti-Jussi.Korjonen@sonera.fi> wrote:
>What I need is a module that acts the same as the Net::Telnet module without
>having to telnet to another computer.
>The resource, I need to access with my script is located at the same computer
>and I need to enter username and password to access it.
>So, first I need to issue command "xxx username" and then password.
>This very much telnet-a-like. After I have logged in to the resource, I can
>issue commands, like "system", "trunk" etc. And I catch that output etc...
>When I'm done, I log out of the resource.
Why don't you just have the computer telnet to itself? Unless you've got
this happening many times at once, the use of various limited resources
probably isn't enough of a concern to merit rewriting your program.
miguel
------------------------------
Date: Wed, 29 Jul 1998 09:01:32 GMT
From: greggman@my-dejanews.com
Subject: Newbie: extracting fields
Message-Id: <6pmodc$tev$1@nnrp1.dejanews.com>
I'm sorry this is such a basic question but I've been looking for over 2
hours for the answer. I must be an idiot. That includes looking in the
current perl docs/faq etc. Maybe I just don't know what to search for. I
could have had this finished in C in about 2 mintues. I need to learn perl
better.
I'm reading a file one line at a time. A typical line looks like this
.fdata.s f'33.011974, f'50.352013, f'-30.042702 ; max
How do I get $1, $2 and $3 to be 33.011974, 50.352013, -30.042702
respectively?
I tried this
/\s*fdata\.s\sf\'([\d\.\-]+),\sf\'([\d\.\-]+),\sf\'([\d\.\-]+).*/;
which clearly (well, not so clearly to me) doesn't work.
In C I think I would do this
(assuming I don't care about precision)
float v1,v2,v3
scanf (" fdata.s f!%f, f'%f, f'%f", &v1, &v2, &v3);
note: in perl, I'm not conserned about using the data as floats, strings
would be better, in fact in this particular case all I'm trying to do is this
print "$1, $2, $3,\n";
Please help.
Thank you.
-gregg tavares
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 29 Jul 1998 10:23:43 GMT
From: Pawel Gajda <pawelg@obop.com.pl>
Subject: Re: Newbie: extracting fields
Message-Id: <35BEF611.1F0466E3@obop.com.pl>
greggman@my-dejanews.com wrote:
>
> I'm sorry this is such a basic question but I've been looking for over 2
> hours for the answer. I must be an idiot. That includes looking in the
> current perl docs/faq etc. Maybe I just don't know what to search for. I
> could have had this finished in C in about 2 mintues. I need to learn perl
> better.
>
> I'm reading a file one line at a time. A typical line looks like this
>
> .fdata.s f'33.011974, f'50.352013, f'-30.042702 ; max
>
> How do I get $1, $2 and $3 to be 33.011974, 50.352013, -30.042702
> respectively?
>
> I tried this
>
> /\s*fdata\.s\sf\'([\d\.\-]+),\sf\'([\d\.\-]+),\sf\'([\d\.\-]+).*/;
>
> which clearly (well, not so clearly to me) doesn't work.
try this:
/\s*\.fdata\.s\s+f\'([\d\.\-]+),\sf\'([\d\.\-]+),\sf\'([\d\.\-]+).*/;
^^ ^
Pawel
------------------------------
Date: 29 Jul 1998 07:42:47 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl5.005: any good Thread::kill workaround ideas?
Message-Id: <6pmjpn$593$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jozsef Hollosi
<hollosi@sbcm.com>],
who wrote in article <35BCFCB6.8A4359AA@sbcm.com>:
> I just built the new Perl5.005 on Digital Unix and I am trying out the
> cool threads.
>
> My first test is a simple network server that starts two threads (reader
> and writer) for
> each accepted connection. The problem is, that when the writer decides
> it is time to
> finish, there is no trivial way to tell the reader to also finish,
> because that is waiting
> on a file descriptor (until there is some activity on that file
> descriptor).
Create a pipe, and make the thread wait on this pipe too. Then write
something to this pipe when you need to wake the kid (This is
a home-grown recipe).
Ilya
------------------------------
Date: Wed, 29 Jul 1998 11:18:57 +0200
From: matteo boschini <boschini@cilea.it>
Subject: perl5.005_01 with threads on HP-UX
Message-Id: <35BEE901.6C08@cilea.it>
Hi all,
I'm trying to install perl5.005_01 WITH thread on a HP-UX 10.20 box.
Installation without thread goes smooth as silk.
When I firts tried the threads thing, I had a make depend problem due to
a wrong (i.m.m.o.) path in include file pthread.h
I solved that but now a make goes into error when cc'ing miniperlmain.c
at line 31 saying "Wrong argument type".
Does anyone have any clue / suggestion ???
Already thanking you,
* Matteo Boschini e-mail: boschini@cilea.it *
* Sys. Admin. *
* Security Team *
------------------------------
Date: 29 Jul 1998 00:18:46 -0700
From: alaric@babcom.com (Mystic Zen Biker Twigboy)
Subject: Test failures compiling perl5.005
Message-Id: <6pmicm$98j$1@babylon5.babcom.com>
The following test failures were reported from 'build_dir/perl harness'
after compiling perl5.005 i586-linux-thread on a linux-2.0.35 system using
libc-5.4.46, linusthreads-0.6, and egcs-1.0.3a:
Failed Test Status Wstat Total Fail Failed List of failed
-------------------------------------------------------------------------------
io/pipe.t 12 2 16.67% 1-2
lib/anydbm.t 12 1 8.33% 12
lib/cgi-functio 24 1 4.17% 23
lib/cgi-request 31 1 3.23% 30
lib/db-btree.t 102 1 0.98% 73
lib/db-hash.t 62 1 1.61% 43
lib/filehand.t 11 1 9.09% 8
lib/io_pipe.t 10 3 30.00% 3, 5-6
lib/open2.t 7 2 28.57% 3, 7
lib/open3.t 0 13 21 15 71.43% 3-4, 9-21
lib/posix.t 18 1 5.56% 2
lib/selectsaver 3 1 33.33% 2
op/closure.t 0 13 169 150 88.76% 20-169
op/stat.t 58 1 1.72% 39
4 tests skipped, plus 14 subtests skipped.
Failed 14/186 test scripts, 92.47% okay. 181/6428 subtests failed, 97.18%
okay.
My questions, as one unfamiliar with the perl test suite:
- How significant are these failures?
- What can I do about them?
- How are they likely to impact me?
Any info/advice will be greatly appreciated.
--
,-- phil stracchino --- the renaissance man --- lone geek biker --.
\ "I know a cat named Easter, he says, Will you ever learn / You're /
\ just an empty cage girl, if you kill the bird..." -- Tori Amos /
`- '91 Camaro Z28 --- '86 VF500F Interceptor --- '91 VFR750F --'
------------------------------
Date: 29 Jul 1998 08:07:40 GMT
From: "Jim Babbington" <jwb79@mail.idt.net>
Subject: Re: Try perl on Ms Dos
Message-Id: <01bdbac6$e1a1cc10$6488fdc7@dixon>
: > Or pulling down the "Save as Type" drop down and selecting "All Files
: > (*.*)" and then typing in whatever you please.
:
:
: or even better: use another editor.
:
Or even, even _better_: use unix :-)
------------------------------
Date: Wed, 29 Jul 1998 00:14:11 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
To: David Deutsch <david@completehost.com>
Subject: Re: WANTED: Perl Autoreponder - Any Takers?
Message-Id: <35BECBC3.7E8C5CD@mcmahon.qal.berkeley.edu>
Check out procmail and formail -- they'll do exactly what you're looking
for, cleanly and quickly.
Regards,
Andy Perrin
David Deutsch wrote:
> I'm in need of a perl based autoreponder that is called from the
> /etc/aliases file. It will be ran under Linux with Sendmail 8.9.x and
> must perform the following functions:
>
> 1) Forward orginal message to a specified recipient
> 2) Send a reply to author based on content from a text file
> 3) Change the replyto, from, and subject to a specified
> setting...
> 4) Must not allow the from and replyto to be set to the
> address of the auoresponder itself (will be passed as a var)
>
> I need this ASAP, I doubt it should take more than an hour or two,
> please send qutoes/questions/rates to me privately at
> david@completehost.com .
>
> --David Deutsch
--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting - (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King
http://socrates.berkeley.edu/~aperrin to e-mail me)
e-mail wheres-andy@socrates.berkeley.edu to find me!
-------------------------------------------------------------
------------------------------
Date: 29 Jul 1998 08:41:55 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Why doesn't 'man perlipc' domain sample code work?
Message-Id: <6pmn8j$muf$1@news.ycc.yale.edu>
Playing around with unix domain sockets, I figured the sample code in the
perlipc manpage (5.004) would be a good starting point.
But it doesn't seem to work quite right: Every other connection (made via
the sample client program) is ignored. (i.e., the first time it works, the
second time the client terminates immediately and the server doesn't report
any incoming connection, the third time it works again).
Any ideas why?
Thanks!
miguel
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 3283
**************************************