[18632] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 800 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 30 09:06:35 2001

Date: Mon, 30 Apr 2001 06:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988635910-v10-i800@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 30 Apr 2001     Volume: 10 Number: 800

Today's topics:
    Re: Boole's tools (was Things I'm just not getting in P (Abigail)
    Re: COMM Port/ Modem Access (David Efflandt)
    Re: First and last element in list loop <mischief@velma.motion.net>
    Re: help me <mischief@velma.motion.net>
        How can I stop at the frist matching <antic@MailAndNews.com>
    Re: How can I stop at the frist matching <bart.lateur@skynet.be>
    Re: Perl and "exec" (David Efflandt)
        Perl Editors? <"relaxedrob@optushome.com.au">
    Re: Perl Editors? <news@simonflack.com>
    Re: Perl Editors? <gtoomey@usa.net>
        Perl script to execute program on NT <ibh@2t.dk>
    Re: Point of using perlcc (Harri Haataja)
    Re: pretty-printing perl? <ilya@math.ohio-state.edu>
    Re: pretty-printing perl? (Rudolf Polzer)
    Re: Question on variable substitution <faulbaum@alder.bessy.de>
    Re: reg exp <perl@dotexpress.com>
    Re: reg exp <news@simonflack.com>
    Re: run by click in linux (Harri Haataja)
    Re: sendmail <news@simonflack.com>
    Re: sendmail <news@simonflack.com>
    Re: sendmail <gasper@cis.ohio-state.edu>
    Re: SGI IRIX fork() syscall: child process doesn't term <mjo@dojo.mi.org>
    Re: Strange string -> num conversion <mischief@velma.motion.net>
    Re: Strange string -> num conversion <bart.lateur@skynet.be>
        Testing whether a socket is still connected <hafner-usenet@ze.tu-muenchen.de>
    Re: tinyweb server <bart.lateur@skynet.be>
    Re: XML::RSS and mod_perl <matt@sergeant.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 30 Apr 2001 09:52:56 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Boole's tools (was Things I'm just not getting in Perl)
Message-Id: <slrn9eqdfo.h4q.abigail@tsathoggua.rlyeh.net>

Chris Stith (mischief@velma.motion.net) wrote on MMDCCXCIX September
MCMXCIII in <URL:news:tepo9glv4e7q07@corp.supernews.com>:
][  
][  I'll bet Abigail's news reader uses Perl to calculate that
][  number. 


No. My newsreader is totally unaware of Perl. But, as any good newsreader
does, you can configure what editor it should use. But the newsreader
doesn't really care whether it's calling an editor, or some other program.
So, mine calls a Perl program that massages the template it gets from
the newsreader, calls the editor and then massages the results before
handing it back to the newsreader.

It's Perl playing the role of glue.



Abigail
-- 
$;                                   # A lone dollar?
=$";                                 # Pod?
$;                                   # The return of the lone dollar?
{Just=>another=>Perl=>Hacker=>}      # Bare block?
=$/;                                 # More pod?
print%;                              # No right operand for %?


------------------------------

Date: Mon, 30 Apr 2001 07:15:05 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: COMM Port/ Modem Access
Message-Id: <slrn9eq47o.sf0.see-sig@typhoon.xnet.com>

On Sun, 29 Apr 2001 20:33:46 -0500, CharlieB <cbbenefit@hotmail.com> wrote:
> Can anyone let me in on the secret? I can't figure out how to connect to my
> modem from perl and dial a pager number (used for system admin purposes)
> under Win32 environment. For example I would like to open COM1 to init the
> modem and dial 555-5555 and place 9090 as the numeric page. NE help would be
> greatly appreciated.

I believe the module is call Win32::Serial for Windows and the Linux
(Unix) port of that is called Device::Serial.

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


------------------------------

Date: Mon, 30 Apr 2001 08:01:46 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: First and last element in list loop
Message-Id: <teq6va2ogof099@corp.supernews.com>

Gregory Toomey <gtoomey@usa.net> wrote:
> This issue abounds in comp.land.perl.misc and practiacllu nowhere else.

> http://www.perlfaq.com/faqs/id/131

> ...

[snip]

> or after it. In fact, if the quoted text is long and not exactly specific to
> the reply, I prefer to see it after the reply. I often follow up with the

If it is not specific to the reply, then it shouldn't be quoted
text. In what school system did they teach you to quote entire
newspaper articles verbatim in your term papers?

This is a question of relevance.

> quoted material after my reply--when I'm not addressing the quoted material
> point-by-point--and although this annoys the heck out of a limited number of
> people who want email and netnews and the like to be just so, it's still
> perfectly readable, and it's the way that I want my postings to look. If the

You mean you do exactly the opposite of what society asks of
you. Isn't that convenient. For three decades other people
figure out that something works, then you come along and you
feel oppressed because it's less convenient for you to take
into consideration the time and effort of the thousands of
others who read this group than to think of yourself first, 
last, and at all times in between.


> meaning is clear, why should I let people tell me what order the parts of my
> message should be in? Personally I think that's an overly pedantic criticism
> of a message. Your view may of course differ.

The meaning of 'You are wrong' at the top of a 10,000 word
post by someone else, which makes eight different points,
is hardly clear and is usually poorly informed as well.

Anyone who has taken the time to actually read a post and
formulate a decent response to it has already scrolled the
post up and down. As a matter of fact, if you post entirely
at the top "to save time scrolling up and down", you either
don't visually see the original post whiole you are typing,
or you have to do _even_more_scrolling_ to make sure you
are posting something relevant and haven't misread or
misunderstood specific parts of the original post. Scroll down
to read a section, scroll up to type at the top? Scroll down
to read another section, scroll back up to type at the top?
How does that save any time? 

If you simply answer that you do not scroll down to reread
the sections you are specifically addressing, then you
probably are not speficially addressing any part of the
original post. If you have instant recall of every letter
and punctuation mark in a post after reading it once, you
are luckier than most of us (and should be playing cards
in a casino for a living instead of writing code and posting
here).

I suppose that if you are British and come to the U.S. or
if you are American and go to the U.K. that you will drive
on the wrong side of the road, since you are more comfortable
that way, and you shouldn't let anyone tell you how things
are done in the culture you've chosen to visit?

Chris

-- 
If they can get you asking the wrong questions, they don't
have to worry about the answers.
  -- Thomas Pynchon, Gravity's Rainbow



------------------------------

Date: Mon, 30 Apr 2001 08:16:11 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: help me
Message-Id: <teq7qbafa6u5c0@corp.supernews.com>

Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> "mein Luftkissenfahrzeug ist voll von den Aalen"
> said Bob Walton (bwalton@rochester.rr.com) in 
> <3AEA157A.1C65BD86@rochester.rr.com>:
>>RS wrote:
>>> I 'm writing counter for my site and I would like to log my guests display
>>> settings (resolution).

>>perldoc -q increment the counter

> I think that the question you answered is not the same question as the
> question that was asked. I don't think you can do this in Perl anyway.

Sure you can, just not in a sneaky way like the OP seems to want.
The CGI protocol was not designed for the server to gather all
sorts of metadata about the user and browser. It also was not
designed to pull a bunch of information from the browser without
the consent of the user. All of that sneaky and ethically
questionable crap is the domain of Netscape, Microsoft, and
INScript. Java can be used for the same ends when run on the
client side.

If you really want to know the diplay size of your user, create
a form that asks and have your program read the answer. If you
want to only have to ask once, use a username and password or
cookies or something to reference some preference settings. This
can be done via CGI from the server side, so Perl or almost any
other language can do this.

Sometimes the technology doesn't matter as much as the reason
why.

Chris

-- 
Parking for people we like only. All other vehicles will be vandalized.



------------------------------

Date: Mon, 30 Apr 2001 08:45:39 -0400
From: Ann Tica <antic@MailAndNews.com>
Subject: How can I stop at the frist matching
Message-Id: <3B0B063F@MailAndNews.com>

I have a variable $var
and I want to extract "8.1.0" from the line if the line starts with 
name[789]
My codes return "7.2.3" ?!

$var = "name shs msk sls ls
name line2 sls sl sl sls 8.0.0.2
name8 line2 sls sl sl sls 8.1.0.2 slsl 7.2.3.1 ddd
7.3.3.0 lsdk line 3lsdk lsdk sl";

$var =~ /^(.*)(name[789].* )([789]\.\d\.\d)/m;
print "$3\n";

any advice ?

Thanks
Antic

------------------------------------------------------------
 Get your FREE web-based e-mail and newsgroup access at:
                http://MailAndNews.com

 Create a new mailbox, or access your existing IMAP4 or
 POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------



------------------------------

Date: Mon, 30 Apr 2001 12:51:00 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How can I stop at the frist matching
Message-Id: <8unqetcu22120ogvrcvj860hbp4d48876q@4ax.com>

Ann Tica wrote:

>I have a variable $var
>and I want to extract "8.1.0" from the line if the line starts with 
>name[789]
>My codes return "7.2.3" ?!

>name8 line2 sls sl sl sls 8.1.0.2 slsl 7.2.3.1 ddd

>$var =~ /^(.*)(name[789].* )([789]\.\d\.\d)/m;
>print "$3\n";

Make the .* right after "name[789]" non-greedy, by adding a question
mark:

$var =~ /^(.*)(name[789].*? )([789]\.\d\.\d)/m;

-- 
	Bart.


------------------------------

Date: Mon, 30 Apr 2001 07:24:34 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Perl and "exec"
Message-Id: <slrn9eq4ph.sf0.see-sig@typhoon.xnet.com>

On Mon, 30 Apr 2001, LXQ <lxq79@REMOVE.CAPITALS.hotmail.com> wrote:
> I tried to execute sudo command from CGI using Perl. I wrote a simple
> script like this:
>  
> exec "sudo /etc/rc.d/init.d/httpd restart";
> 
> But the problem is sudo will not run the command directly, it will display
> a password prompt first. How can I send the password to the shell after I
> send the exec?...

Since you have to be root to do that anyway, why not use suidperl instead 
of perl, make the script suid root, and then you can su without a 
password.  But you should take other precautions (crypted password) 
for accessing the script, and if CGI you probably need to fork it off or 
daemonize it first, in case restarting apache would kill it (see: perldoc 
perlipc).

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


------------------------------

Date: Mon, 30 Apr 2001 11:07:05 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: Perl Editors?
Message-Id: <tHbH6.51243$Xx3.291123@news1.eburwd1.vic.optushome.com.au>

Howdy all!

I am using ActivePerl for Windows and would really like to get my hands on a
decent Perl editor that would at the very least allow me to run a script,
accept standard input and display standard output ok.

I have been using UltraEdit and Kawa. They are both good editors (Kawa is
great for java in particular) but neither do a great job on accepting input
for perl..

any ideas anyone?

Thanks!

Rob




------------------------------

Date: Mon, 30 Apr 2001 12:54:30 +0100
From: "Simon Flack" <news@simonflack.com>
Subject: Re: Perl Editors?
Message-Id: <9cjk6j$e2jbg$1@ID-83895.news.dfncis.de>

Ultraedit is my favorite, but I am about to try Komodo from ActiveState.

Simon

"Rob" <"relaxedrob@optushome.com.au"> wrote in message
news:tHbH6.51243$Xx3.291123@news1.eburwd1.vic.optushome.com.au...
> Howdy all!
>
> I am using ActivePerl for Windows and would really like to get my hands on
a
> decent Perl editor that would at the very least allow me to run a script,
> accept standard input and display standard output ok.
>
> I have been using UltraEdit and Kawa. They are both good editors (Kawa is
> great for java in particular) but neither do a great job on accepting
input
> for perl..
>
> any ideas anyone?
>
> Thanks!
>
> Rob
>
>




------------------------------

Date: Mon, 30 Apr 2001 23:02:09 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Perl Editors?
Message-Id: <Y9dH6.14705$482.76668@newsfeeds.bigpond.com>


"Rob" <"relaxedrob@optushome.com.au"> wrote in message
news:tHbH6.51243$Xx3.291123@news1.eburwd1.vic.optushome.com.au...
> Howdy all!
>
> I am using ActivePerl for Windows and would really like to get my hands on
a
> decent Perl editor that would at the very least allow me to run a script,
> accept standard input and display standard output ok.
 ...

I haven't tried it yet, but the Arachnophilia HTML editor comes with a Perl
editor and beautifier.
www.archnoid.com





------------------------------

Date: Mon, 30 Apr 2001 13:51:29 +0200
From: "Ib Hansen" <ibh@2t.dk>
Subject: Perl script to execute program on NT
Message-Id: <9cjldj$8ij$1@news.inet.tele.dk>

Hi,

As a newbie i am trying to execute a program using Perl.

I need to have an object i can  click on i a HTML document, so that i can
execute a program

I wrote the following script, but it does not work can anybody help

$| = 1;

$Q = new CGI;

print $Q->header(),
 $Q->start_html(),
 "<h1>Output from script</h1>\n",
 "<p>EXPECT1:", `expect.exe reset.exp 1`,
 $Q->end_html();

Thanks in advance

Ib





------------------------------

Date: Mon, 30 Apr 2001 09:52:12 GMT
From: harri@tolppa.kotisivupalvelu.fi (Harri Haataja)
Subject: Re: Point of using perlcc
Message-Id: <slrn9eqdh7.5nm.harri@tolppa.kotisivupalvelu.fi>

flash top-posted:
>But doesn't the compiled program only work on the os it was compiled on?

That tends to be a property of binary code (leaving aside fat, bytecode etc).

>So therefor if perl was standard couldn't you assume that it would be there.

If you look at "programs" made with perl, how many come compiled and
how many as "source", assuming standard /usr/bin/perl?

>I agree that it is good for usin when you have 5+ modules
>(i use 6 seperat ones in a script(using require statment))

-- 
"Dump was a stupid program in the first place. Leave it Behind"
	-- Linus Torvalds



------------------------------

Date: 30 Apr 2001 08:56:32 GMT
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: pretty-printing perl?
Message-Id: <9cj9c0$nb9$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Tad McClellan
<tadmc@augustmail.com>], who wrote in article <slrn9eosdn.dfk.tadmc@tadmc26.august.net>:
> >Is there a pretty-printer for perl? 

> Is there a Perl FAQ? 
> 
> Yes.
> 
> Are you expected to check the Perl FAQ before posting to the
> Perl newsgroup? 
> 
> Yes.
> 
> Please try that first in the future:
> 
>    perldoc -q pretty-printer
> 
>       "Is there a pretty-printer (formatter) for Perl?"

Is there any reason to trust the Perl FAQ?

No.

See the menu in cperl-mode.

Ilya


------------------------------

Date: Mon, 30 Apr 2001 11:04:08 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: pretty-printing perl?
Message-Id: <slrn9eqak8.nd5.eins@www42.t-offline.de>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> [A complimentary Cc of this posting was sent to
> Tad McClellan
> <tadmc@augustmail.com>], who wrote in article <slrn9eosdn.dfk.tadmc@tadmc26.august.net>:
> > >Is there a pretty-printer for perl? 
> 
> > Is there a Perl FAQ? 
> > 
> > Yes.
> > 
> > Are you expected to check the Perl FAQ before posting to the
> > Perl newsgroup? 
> > 
> > Yes.
> > 
> > Please try that first in the future:
> > 
> >    perldoc -q pretty-printer
> > 
> >       "Is there a pretty-printer (formatter) for Perl?"
> 
> Is there any reason to trust the Perl FAQ?
> 
> No.
> 
> See the menu in cperl-mode.

You will have to undo some changes, however. Only perl can parse Perl.

Try (I did not check it):

eval <<'{';
        my $a = 3;
        for (;$a<6;$a++)
        {
         ++$i;
        }
{

This should confuse your formatter.

-- 
#!/usr/bin/perl -W -- WARNING: This copies a random file from
use strict;my$s;my$n=0;for # the  current  directory  to your 
(<*>){++$n;int rand$n or$s # signature  file.   Use  at  your
=$_};`cp $s ~/.signature`; # own risk! (c) 2001 Rudolf Polzer


------------------------------

Date: 30 Apr 2001 10:37:53 +0200
From: Dieter Faulbaum <faulbaum@alder.bessy.de>
Subject: Re: Question on variable substitution
Message-Id: <vsk842kcke.fsf@alder.bessy.de>


Thank you very much, nobull!

nobull@mail.com writes:

> Dieter Faulbaum <faulbaum@alder.bessy.de> writes:
 ...
> > this is an excerpt from a perl file,
> 
> Do not post excerpts.  Produce a small but complete script to
> illustrate your question.  Otherwise we cannot be sure if we are
> dealing with your original problem or an artifact of your
> transcription errors.

Okay, next time I will try to do it better! I see, that I made errors
by the transcription. And the hope, that (all) other programmers
understand what I want, was a pie in the sky (as I see in the posting
from Tad McClellan). But I saw, that _you_ understand it (and made the
necessary completions).
I learned a lot from your answer, so thank you very, very much!

Dieter


------------------------------

Date: Mon, 30 Apr 2001 19:26:38 +0800
From: "Tommy Au" <perl@dotexpress.com>
Subject: Re: reg exp
Message-Id: <9cji2d$kme$1@news.ust.hk>

try this:
$var =~ s/\s+/\%/g;

--
¡¯¢×¢Ñ¢ß¡­¡G¢³¢¸¢¶¢°¢¶¢¸


Troy Boy <troyr@vicnet.net.au> wrote in message
news:rE7H6.2570$VM5.79241@ozemail.com.au...
> Hi there
>
> say $var="-rwxr-xr-x    1 troyr    staff         101 Apr 30 16:22
test.cgi";
>
> I want to make a reg ex that replaces all spaces with 1 percentage sign
>
> If i do $var=~ s/ /%/g ;
>
> It replaces every occurence making var
>
="-rw-r--r--%%%%1%troyr%%%%staff%%%%%2435905%Mar%21%10:30%/home/troyr/210300
> .txt"
>
> Does anyone know of a way to make it only replace spaces which are
together
> with 1 % sign
>
> ie between troyr and staff should only be 1 % sign not 4
>
> Thanks in advance
>
> --
> ----------------------------------------------------------------
> Troy Rasiah
> Melbourne, Aus
>
>




------------------------------

Date: Mon, 30 Apr 2001 12:36:56 +0100
From: "Simon Flack" <news@simonflack.com>
Subject: Re: reg exp
Message-Id: <9cjj2m$eahpg$1@ID-83895.news.dfncis.de>

> For single character translations you should look into the tr/// (y///)
> operator.  Not only is it faster than s///, it also has a modifier to do
> exactly what you want.
>
> read about it in perlop.
>
> For what you want, tr/ /%/s should do the trick
>
> Wyzelli

He doesn't want single character traslations - he wants s/\s+/%/g

Assuming that he later wants to split the string into an array he could
split on '%', but he could also avoid that step by just doing this:
split /\s+/, $string;

Simon




------------------------------

Date: Mon, 30 Apr 2001 09:53:48 GMT
From: harri@tolppa.kotisivupalvelu.fi (Harri Haataja)
Subject: Re: run by click in linux
Message-Id: <slrn9eqdk8.5nm.harri@tolppa.kotisivupalvelu.fi>

Jonathan Stowe wrote:
>Ying Hu <yhu@mail.nih.gov> wrote:
>> hi,
>> how can I run one perl script by click the icon in Linux. Thanks
>> 
>
>I would read the documentation for your window manager.

Icons shouldn't be on the hands of a window manager IMHO.
At least not those that start a program when clicked.

So s/your window manager/your desktop or file manager/ .

-- 
"Dump was a stupid program in the first place. Leave it Behind"
	-- Linus Torvalds



------------------------------

Date: Mon, 30 Apr 2001 12:19:30 +0100
From: "Simon Flack" <news@simonflack.com>
Subject: Re: sendmail
Message-Id: <9cji55$eac3g$1@ID-83895.news.dfncis.de>

"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:bW5H6.9$lX5.1370@vic.nntp.telstra.net...

> A search for "sendmail for windows" on www.google.com gives over 1000
hits.
> I guess one of those would be OK.  I personally use the one you would get
> from the "I'm Feeling Lucky" hit.

Actually, he can just download Mail::Sendmail from the ActiveState
repository. No for system call or backticks to a binary. He did ask for a
perl module as well.

Simon




------------------------------

Date: Mon, 30 Apr 2001 12:31:33 +0100
From: "Simon Flack" <news@simonflack.com>
Subject: Re: sendmail
Message-Id: <9cjis1$dtsm1$1@ID-83895.news.dfncis.de>

"Keith G" <gasper@cis.ohio-state.edu> wrote in message
news:9cimi7$ire$1@news.cis.ohio-state.edu...
> i'm looking for a way to get the sendmail module that will
> work with active perl for windows. anyone know of a
> site that has it? thanks!
> keith

Hi Keith,

Type "ppm install Net::Sendmail" in a command prompt.

I think ActiveState only have the Net::Sendmail module for perl 5.6 - so if
you aren't using ActiveState 623 or above - you won't be able to download
it.
So I would advise either upgrading to ActiveState 623 - its an 8MB download.
or download the module from CPAN(.org) and install it manually.

Simon





------------------------------

Date: Mon, 30 Apr 2001 08:02:28 -0400
From: "Keith G" <gasper@cis.ohio-state.edu>
Subject: Re: sendmail
Message-Id: <9cjk4s$67r$1@news.cis.ohio-state.edu>

ah, thank you. this is what I was looking for!
keith


"Simon Flack" <news@simonflack.com> wrote in message news:9cjis1$dtsm1$1@ID-83895.news.dfncis.de...
> "Keith G" <gasper@cis.ohio-state.edu> wrote in message
> news:9cimi7$ire$1@news.cis.ohio-state.edu...
> > i'm looking for a way to get the sendmail module that will
> > work with active perl for windows. anyone know of a
> > site that has it? thanks!
> > keith
>
> Hi Keith,
>
> Type "ppm install Net::Sendmail" in a command prompt.
>
> I think ActiveState only have the Net::Sendmail module for perl 5.6 - so if
> you aren't using ActiveState 623 or above - you won't be able to download
> it.
> So I would advise either upgrading to ActiveState 623 - its an 8MB download.
> or download the module from CPAN(.org) and install it manually.
>
> Simon
>
>
>




------------------------------

Date: Mon, 30 Apr 2001 11:38:23 GMT
From: Mike O'Connor <mjo@dojo.mi.org>
Subject: Re: SGI IRIX fork() syscall: child process doesn't terminate after exit
Message-Id: <010430113823.AA25272@dojo.mi.org>

In article <tepu2j3adg23eb@corp.supernews.com>,
Chris Stith  <mischief@velma.motion.net> wrote:
:In comp.lang.perl.misc Brent Casavant <bcasavan@sgi.com> wrote:
:> [posted and replied]
:
:> On 25 Apr 2001, Matthew Black wrote:
:
:>> PROBLEM:
:>> We are having trouble with the fork() system call in Perl.
:
:Really?
:
:>> When a child process exits, the process lingers as
:>> <defunct> rather than disappearing. These lingering
:>> <defunct> processes disappear only after the parent
:>> process gets terminated.
:
:This is a problem of not waiting on the children. Learn
:how to use the tools before you blame them for your
:mistakes.
:
:> Well, I'll admit to not being a Perl guru, but I'm
:> pretty sure I know what the problem is.
:
:> The parent process needs to catch the SIGCHLD signal,
:
:Catching SIGCHGLD is not necessary, but this is a good
:way to trigger a wait since it allows the wait to be
:called in a timely manner and also allows the parent to
:do other work instead of just blocking to wait on the
:children.
:
:> then perform a "wait()" system call to read the child's
:> exit status. This is necessary because the kernel cannot
:> free up the child's state (including the exit status)
:> until somebody reads that exit status. You are observing
:> child processes stuck in the "zombie" (not quite dead,
:> not quite alve) state.
:
:> The reason they go away when the parent exits is that
:> the children are inheirited by the init process (pid 1),
:> which always catches SIGCHLD and performs a wait(),
:> causing the zombies to die for good.
:
:Setting the value of $SIG{CHLD} to 'IGNORE' will allow
:you to not worry about cleaning up after your children
:on some platforms.
:
:>> This problem was observed on our
:>> Origin 200 systems running IRIX 6.5.x  (6.5.10m  and 6.5.6m).
:>> It did NOT occur with a Challenge S running IRIX 6.2.
:
:This is intgeresting. I will venture to say that the
:Challenge S with IRIX 6.2 is the odd machine here, if
:a Perl explanation indeed cannot be found. It's interesting
:that people tend to think of what they know as being right
:and what has changed to be wrong, even if this is in fact
:directly opposed to reality and standards.

FWIW, I never got as far as looking at the perl code because I
couldn't replicate the reported behavior on an IRIX 6.5.current
Origin either.  So I know of at least two "odd" machines.

--
 Michael J. O'Connor | WWW: http://dojo.mi.org/~mjo/ | Email: mjo@dojo.mi.org
 Royal Oak, Michigan | (has my PGP & Geek Code info) | Phone: +1 248-427-4481



------------------------------

Date: Mon, 30 Apr 2001 07:30:03 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Strange string -> num conversion
Message-Id: <teq53rorokbb6@corp.supernews.com>

Todd Smith <todd@designsouth.net> wrote:
> Here's my research contribution (Cobalt Linux 5,  Raq3):

> [tbsmith@raq300 tbsmith]$ perl -le "print '0x12' + 1"
> 2.125
> [tbsmith@raq300 tbsmith]$ perl -le 'print "0x12" + 1'
> 2.125
> [tbsmith@raq300 tbsmith]$ perl -le "print 0x12 + 1"
> 19
> [tbsmith@raq300 tbsmith]$ perl -v

> This is perl, version 5.005_03 built for i386-linux

Here ya go:

[mischief@mischief mischief]$ uname -a
Linux mischief 2.2.14-15mdksecure #1 SMP i586 unknown

[mischief@mischief mischief]$ perl -le 'print 0x12 + 1'
19
[mischief@mischief mischief]$ perl -le 'print "0x12" + 1'
2.125
[mischief@mischief mischief]$ perl -le "print '0x12' + 1"
2.125
[mischief@mischief mischief]$ perl -le "print (0x12 + 1)"
19
[mischief@mischief mischief]$ perl -le 'print (0x12 + 1)'
19
[mischief@mischief mischief]$ perl -v

This is perl, version 5.005_03 built for i386-linux

This really is a Perl issue. Look at this:

[mischief@mischief mischief]$ perl
print "0x12" + 1;
print "\n";
2.125

There's no shell there. This is even curioser:

[mischief@mischief mischief]$ perl
print "0x12" + 1;
print "\n";
$foo = "0x12";
print $foo . "\n";
$foo += 0;
print $foo . "\n";
$bar = '0x12';
print $bar . "\n";
$bar = $bar + 0;
print $bar . "\n";
2.125
0x12
1.125
0x12
1.125

What the heck? It appears that perl doesn't realise it's a
number because of the 'x'. What is worse is how it handles
adding zero to it.

Here it's clear that perl thinks it's a hex number:

[mischief@mischief mischief]$ perl
$foo = 0x12;
print $foo . "\n";
18

This is a serious lack of consistency with how numbers in
decimal base are treated. I'd call that a bug if i didn't
have something else to call it. 5.6.0 shows the same behavior:

$ perl
$foo = '0x12';
print $foo . "\n";
$foo += 0;
print $foo . "\n";
$foo = '0x12';
print $foo . "\n";
$foo = ( $foo + 0 );
print $foo . "\n";
$foo = '0x12';
print $foo . "\n";
$bar = 0;
$bar = $foo + 0;
print $bar . "\n";
0x12
1.125
0x12
1.125
0x12
1.125

[mischief@velma ~]$ /usr/local/bin/perl -v

This is perl, v5.6.0 built for i686-linux

Since the hex() and oct() functions will take care of this
mess for us, I'd say it's probably not a bug in perl. Since
perldoc perlvar says the following, I can't call it a doc
bug any more than an implementation bug:


       Octal or hex representations in string literals (e.g.
       '0xffff') are not automatically converted to their integer
       representation.  The hex() and oct() functions make these
       conversions for you.  See the hex entry in the perlfunc
       manpage and the oct entry in the perlfunc manpage for more
       details.

What I can say about it is that it's not very DWIM. Perhaps
the docs should make this a little clearer, because even though
I had my suspicion about why this was all happening, I had to
dig through the docs a bit to find it. I expected the FAQ to
jump up with something, but it has nothing for search string 'hex'
and the enbtry for 'oct' mentions that outside data will not
be recognized, but says nothing about converting string literals
within the program into numbers. Patches to perlfaq4.pod are
welcome, I'm sure. I might do this myself when I'm more rested.

Chris

-- 
Where there's a will, there's a lawyer.



------------------------------

Date: Mon, 30 Apr 2001 07:35:07 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Strange string -> num conversion
Message-Id: <g95qetkvu2r4vikgesmaorh7uhnu71831l@4ax.com>

Chris Stith wrote:

>This really is a Perl issue. Look at this:
>
>[mischief@mischief mischief]$ perl
>print "0x12" + 1;
>print "\n";
>2.125
>
>There's no shell there. 

The shell has nothing to do with it. People here have been claiming that
this behaviour depends on the linkled in C library.

If perl were to include a standard functionality instead of depending on
external 3rd party libraries, just as with (s)printf, at least the
behaviour would be platform independent. Er... except for the internal
representation of the numbers, that is...

-- 
	Bart.


------------------------------

Date: 30 Apr 2001 09:31:02 +0200
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: Testing whether a socket is still connected
Message-Id: <srj4rv6c095.fsf@w3proj1.ze.tu-muenchen.de>

Hi there,

me again with another question. :-)

I just installed Big Brother (http://bb4.com) to monitor my servers
and notify me in case of an emergency. Big Brother makes it easy to add
plugins for user defined tests - all you have to do is write a short
script that does the test and sends it back to the BB daemon.

A while ago I programmed a simple daemon  - it receives a one line query
via an internet socket, responds to the query and terminates the
connection. I use it e.g. to check the validity of ZIP or area phone
codes in web forms online. The daemon queries an underlying MySQL DB for
these tasks. The approach works fine.

Now I want to check whether the daemon hangs. While the check is easy
enough, there is a different problem:

- If the daemon runs, everything is ok
- If it hangs and the socket is unavailable it's ok, too
- If it accepts the connection but doesn't send a response I'm in
  trouble. In that case the connection blocks and my test hangs.

I need some kind of timeout for the test routine. All I can think of is
the following:

- for every test the BB plugin forks off a child that performs the real
  test.
- the parent process does an alarm() and checks after a number of
  seconds whether the child is still running. In that case it kills the
  child and sends a failure notice to BB.
- If the child isn't alive anymore, it sends a success notice.

With this approach I'm only able to send a binary message back to the BB
server, not the real daemon response. If I wanted to do this, I'd have
to implement some kind of IPC between father and child - that's too much
trouble for this simple task, imho.

Can anyone suggest a different, better, simpler, more elegant
etc. approach to handle this? Pseudo-code is fine. I think I only need
to be pointed to the direction to go.

Thanks!

-Walter


------------------------------

Date: Mon, 30 Apr 2001 10:09:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: tinyweb server
Message-Id: <hfeqet4tm76djrad0qtl1k3h5pm0suegp0@4ax.com>

jtjohnston wrote:

>Has anyone succeeded in getting Perl to run in
>http://www.ritlabs.com/tinyweb/ ?

Yes.

What's your problem?

-- 
	Bart.


------------------------------

Date: Mon, 30 Apr 2001 09:38:11 +0100
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: XML::RSS and mod_perl
Message-Id: <3AED2473.D43308B6@sergeant.org>

Matt Morton-Allen wrote:
> 
> Hi again,
> the thing is I can't get this to work. I compile apache (1.3.19) and all is
> good (the proposed strings test on the AxKit FAQ shows no plain text XML
> references in the binary). But after compiling mod_perl (1.25) the XML
> references are back in the binary! I use EVERYTHING=1 to get my other
> requirements so I tried that off to no effect. I also tried the apache
> directive to mod_perl with no effect. What am I missing?

Try the following recipe for compiling Apache and mod_perl:

(run in the mod_perl directory)

 $ perl Makefile.PL \
 > EVERYTHING=1 \
 > USE_APACI=1 \
 > DYNAMIC=1 \
 > APACHE_PREFIX=/opt/apache \
 > APACHE_SRC=../apache_1.3.12/src \
 > DO_HTTPD=1 \
 > APACI_ARGS="--enable-module=so --enable-shared=info 
 > --enable-shared=proxy --enable-shared=rewrite 
 > --enable-shared=log_agent"
 $ make
 $ su
 $ make install


-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\


------------------------------

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.  

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 800
**************************************


home help back first fref pref prev next nref lref last post