[9249] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2844 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 11 16:17:24 1998

Date: Thu, 11 Jun 98 13:00:31 -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           Thu, 11 Jun 1998     Volume: 8 Number: 2844

Today's topics:
    Re: [META] hypersensitivity <jdporter@min.net>
    Re: [META] hypersensitivity <upsetter@ziplink.net>
        access to a hash of lists <jcartwright@wans.net>
        access to a hash of lists <jcartwright@wans.net>
        Adding ~/directory to lib path <rbowen@databeam.com>
    Re: base64 encoding <JKRY3025@comenius.ms.mff.cuni.cz>
    Re: Care to check a script of mine? <rootbeer@teleport.com>
        ceil or trunc <vgopinat@cisco.com>
    Re: Certified Perl Programmers <jdporter@min.net>
    Re: CFV: comp.lang.perl.moderated moderated (John Klassa)
    Re: CFV: comp.lang.perl.moderated moderated (Eric Eisenhart)
    Re: Command line substitution thru subdirectories (Jonathan Stowe)
    Re: Command line substitution thru subdirectories <upsetter@ziplink.net>
    Re: comp.lang.perl.(n|q) another option? (Jonathan Stowe)
    Re: create RTF file on the fly? (Jonathan Stowe)
    Re: Document contains no data? <upsetter@ziplink.net>
    Re: Domino 4.6 on NT 4 -- what perl for CGI's? (Jonathan Stowe)
    Re: Eval questions. (Charles DeRykus)
    Re: Having problems locating a bug!  Can anyone help? - (Jonathan Stowe)
    Re: http protocol <cdh@CompleteIS.com>
        I want threads, threads and more threads! <gabriele@kollwitz.doit.wisc.edu>
    Re: MCNY Express - Your Emergency 911# For Web Developm (Jonathan Stowe)
    Re: MODERATION: Time to Vote <*@qz.to>
        network monitoring (perl daemon), should dump data to s (John Ruckstuhl)
    Re: Opening Files (Tom Harrington)
    Re: Passing variables from bourne script to perl script <devs@usa.net>
    Re: PASV <gabriele@kollwitz.doit.wisc.edu>
        question on a process mgmt (how to kill a child process <ghersh@bbnplanet.com>
    Re: Return characters from a string (Mike Stok)
    Re: Stages in a pipeline <sbronson@opentv.com>
        Suche ein Perl Buch <martini@okay.net>
    Re: Using SDBM and Hashes of Hashes. Is it possible? Ho (Mike Stok)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 11 Jun 1998 19:06:14 GMT
From: John Porter <jdporter@min.net>
Subject: Re: [META] hypersensitivity
Message-Id: <35802C15.3D11@min.net>

jimbo@soundimages.co.uk wrote:
> 
> For the record, I believe Perl and its documentation ranks as high as
> it is possible for software and documentation to rank, if there is
> such a ranking. 

There is a man, whose initials are rms -- a brilliant, pioneering, and
widely respected computer scientist; he would disagree with you on this
point.  He attempted to learn Perl from the provided documentation, and 
gave up in utter frustration.  So how good can the be really?

John Porter

P.s. My experience was not like rms's.


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

Date: 11 Jun 1998 19:13:06 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: [META] hypersensitivity
Message-Id: <6lpa82$iih@fridge.shore.net>

Tom Christiansen <tchrist@mox.perl.com> wrote:

: The problem, in a nutshell, is that whenever we point out a simple and
: obvious--sometimes even elegant--solution, one which inevitably involves
: gluing together other tools (which, I must point out, was what Perl
: *designed* for), we get back nothing but flames from those who cannot
: help themselves.

Whoa, whoa, whoa.....

Here are two previous postings from this thread:

1)
: C:\temp>perl -i.orig -pe 's/\bfoo\b/bar/g' `find / -name '*.htm' -print`
: Can't open `find: No such file or directory

2)
: Stop bitching about not having tools.  It's not our fault that you're
: too lazy, stupid, or rude to bother to install an operating system.

Now, *which* one of these is a flame?

--Art

--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
            http://www.ziplink.net/~upsetter/ska/calendar.html
--------------------------------------------------------------------------


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

Date: Thu, 11 Jun 1998 12:39:57 -0600
From: John Cartwright <jcartwright@wans.net>
Subject: access to a hash of lists
Message-Id: <3580247C.4EEACD50@wans.net>

Hello All,

I am trying to get a list representing the first list element in every
hash element.  For example, if

%HoL = (
       "flintstones"        => [ "fred", "barney" ],
       "jetsons"            => [ "george", "jane", "elroy" ],
       "simpsons"           => [ "homer", "marge", "bart" ],
     );

what I would like is a list with ("fred","george","homer")

I have been trying variations on the following statement but without
success.

@a = @{values %HoL}[0];


Can someone suggest a way that I can retrieve the desired values?

Thanks!

--john
jcartwright@wans.net



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

Date: Thu, 11 Jun 1998 12:40:29 -0600
From: John Cartwright <jcartwright@wans.net>
Subject: access to a hash of lists
Message-Id: <3580249C.FDE503EF@wans.net>

Hello All,

I am trying to get a list representing the first list element in every
hash element.  For example, if

%HoL = (
       "flintstones"        => [ "fred", "barney" ],
       "jetsons"            => [ "george", "jane", "elroy" ],
       "simpsons"           => [ "homer", "marge", "bart" ],
     );

what I would like is a list with ("fred","george","homer")

I have been trying variations on the following statement but without
success.

@a = @{values %HoL}[0];


Can someone suggest a way that I can retrieve the desired values?

Thanks!

--john
jcartwright@wans.net



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

Date: Thu, 11 Jun 1998 15:25:23 -0400
From: Rich Bowen <rbowen@databeam.com>
Subject: Adding ~/directory to lib path
Message-Id: <35802F23.1E3A@databeam.com>

I am looking for a way to add a user directory, like ~/modules, to the
Perl lib path, so that users can put their own modules in their own
/home/user/modules directory and have those modules available to Perl
without having to push @INC, '/home/user/modules/' in every script. 
Thie is a way that users can use modules without having them actually
installed.  The reason for this is that the users in question are
developing code, and the sysadmin does not want to install these modules
on the server.

I'm hoping that this can be generic enough that ~/modules could be in
the search path, and would get expanded, of course, depending on which
user was running the script, at runtime.  Another requirement, just to
be difficult, is that many of these scripts are running as CGI, so there
is not the opportunity to just set an environment variable on login. 
Scripts are running under CGIwrap, so they are actually run as the
correct user.

Any help/suggestions greatly appreciated.

Rich
-- 
##################################################
#  Rich Bowen                                    #
#  Web Services Engineer - DataBeam Corporation  #
#  rbowen@databeam.com                           #
##################################################


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

Date: Thu, 11 Jun 1998 21:07:20 -0700
From: Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz>
Subject: Re: base64 encoding
Message-Id: <3580A978.1E3C@comenius.ms.mff.cuni.cz>

On 8 Jun 1998, Vitali Chkebelski wrote:

> I'm sending mail with mime-attachments encoded with perl MIME-library
> function encode_base64.
>
> They are good understood by Netscape mail-client, but not by MS Exchange
> and Eudora.
> The comparison between source text of mine and those of Netscape message
> shows a slight difference in encoding of the same file (for example
> gif-file).

Are you encoding the file as a single scalar or split into parts?

If you do something like this

	open GIF,"<$filename";
	while (read GIF,$data,$chunksize,0) {
		print OUTPUT encode_base64($data);
	}
	close GIF;

you may encode the file incorrectly. Instead of an even block of
characters, you may get some lines shorter or even terminated by some 
equals (=). You have to use proper $chunksize.

I use 
	my $chunksize=1024*3;
in Mail::Sender ( http://www.fmi.cz/private/Jenda ) with no problems
whatsoever.

HTH, Jenda


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

Date: Thu, 11 Jun 1998 19:13:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Care to check a script of mine?
Message-Id: <Pine.GSO.3.96.980611094341.5401i-100000@user2.teleport.com>

On Thu, 11 Jun 1998, Aloud.com wrote:

> The induhviduals who commisioned the script aren't happy with the speed.
> They have boosted the bandwith of the second webserver so the connection
> is fast. Now that they have address everything else, the finger is now
> pointing at our scripts. We don't know how to optimise the script any
> further. Is there any one out there who would look over our script and
> suggest areas of improvements?

I'm not a person who has time to look over scripts at the moment, but here
are my opinions on this sort of thing. (Whether you thought you were
asking for my opinions or not. :-) 

Maybe your script is especially slow at what it's doing, or maybe it
isn't. But in any case, Perl programs are not-infrequently accused of
being too slow, often on the grounds that "since Perl programs aren't
compiled, they can't be as fast as C programs." As with other half-truths,
there's more to the story. 

Although you could speed nearly any Perl program somewhat by re-writing in
C and compiling, in practice nearly all competently-written real-world
Perl scripts won't show as much better performance as one might naively
expect from that "compiled is always faster" argument. And, of course,
there are some disadvantages to re-writing your program in C. (Hey, if you
wanted it written in C you would have done that from the start, right? :-) 

Having said all that, it may be that your script actually is spending much
of its time doing something which could be sped up. Generally, the way to
find out is to profile your script. This will frequently tell you that
your process is spending over 95% of its time running less than 5% of your
code. So, instead of optimizing the whole program, you could work on
optimizing just the part which makes the difference. You can read about
the Perl profiler in the perldebug manpage. 

That one slow part of your program could be improved by means of a better
algorithm in many cases. But if you're doing something which is relatively
difficult in unadorned Perl, such as intensive bit manipulation or
multiplying 2000-digit integers, it may be that compiled code in the form
of a module will help. 

An important rule is not to optimize your program too soon. Generally, you
should wait until all of the features and debugging are done and it's been
run for a while. That's because it will often take you as much time
optimizing as it took to write the program in the first place! And if you
change anything important, you'll may need to re-do the optimization. 

Here's a reference to a message about optimization that may help you to
know more about what to look for in your own programs. 

     http://www.rosat.mpe-garching.mpg.de/mailing-lists/perl-porters
          /1998-05/msg01406.html

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 11 Jun 1998 12:20:37 -0700
From: Gopinath Venkataramanan <vgopinat@cisco.com>
Subject: ceil or trunc
Message-Id: <35802E04.993E17A4@cisco.com>

Hi

Is there a ceil or trunc function in perl (to round off numbers)

thanx for ur time.



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

Date: Thu, 11 Jun 1998 19:00:09 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Certified Perl Programmers
Message-Id: <35802AB0.48E1@min.net>

You go, Boy!

Wow, what did *you* smoke for lunch today?

John Porter


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

Date: 11 Jun 1998 19:13:15 GMT
From: klassa@aursgh.aur.alcatel.com (John Klassa)
Subject: Re: CFV: comp.lang.perl.moderated moderated
Message-Id: <6lpa8b$qos$1@aurwww.aur.alcatel.com>

On 11 Jun 1998 17:36:21 GMT, John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
->In article <6lop9h$ajj$5@info.uah.edu>, Greg Bacon <gbacon@cs.uah.edu> wrote:
->>In article <6loasp$3ol$2@bsdti6.sdm.de>,
->>	Steffen Beyer <sb@sdm.de> writes:
->>: In other words, the people frequenting this newsgroup will have *NO*
->>: democratic means of controlling the moderation panel.
->>
->>There will be a public mailing list for people interested in the group's
->>policies.  Moderators are appointed and removed by a two-thirds majority
->>vote.  
->
->Of the moderation panel. Not the readership.

Personally, I don't see the problem...  I trust the people who will be on
the moderation panel, and expect the new group to be vastly more useful
than this one (due, largely, to the change in the S/N ratio).  There isn't
a bad guy lurking around every corner, after all (i.e. there's no reason to
assume the worst, here; rather, it seems rather appropriate to assume the
best).

[ Not picking on you in particular, John Stanley -- I'm mostly just adding
  my $0.02 to the debate. :-) ]

-- 
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><


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

Date: 11 Jun 1998 12:55:46 -0700
From: eric@sonic.net (Eric Eisenhart)
Subject: Re: CFV: comp.lang.perl.moderated moderated
Message-Id: <6lpco2$5u0@bolt.sonic.net>

In article <6lp45m$sm1$1@news.NERO.NET>,
John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>Yes, and when you are in DejaNews, you might wander through the
>perl.porters-gw archive. That is where the request for volunteers was
>made. If you weren't on that mailing list/newsgroup, you didn't know
>there was a chance to volunteer, until the RFD with the list of proposed
>moderators was posted.

I'm very passively on perl5-porters.  I never saw/noticed a message
requesting volunteers.  Yet, somehow, I managed to volunteer after seeing
the first RFD.
-- 
               Eric Eisenhart -- http://www.eric.eisenhart.com
    Help, I've gotten stuck in this .sig and I don't know how to get out!


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

Date: Thu, 11 Jun 1998 19:02:33 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Command line substitution thru subdirectories
Message-Id: <358018ba.2991380@news.btinternet.com>

On Thu, 11 Jun 1998 15:25:02 GMT, Jason Turner wrote :

>On Tue, 09 Jun 1998 17:11:05 -0400, Bob Roklan posted
><357DA4E9.DA495FD6@code80.npt.nuwc.navy.mil>:
>
>> I am running Perl 5.003 on Windows 95.
><...>
>>    perl -i.old -p -e "s/foo/bar/g" *.htm
>>
>>but how can I tell perl to do the same for a specified directory and
>>down?
>
>Hi Bob, you're a military man.  How would the A-Team do it?
>
>Jason, who finds the analogy rather amusing.
>
<etc>

Titter, titter.

And I was just reminiscing about how the "list" command on the Amiga
used to allow you generate a command for each file found ...

You'd better send me that A-Team theme 

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 11 Jun 1998 19:14:31 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Command line substitution thru subdirectories
Message-Id: <6lpaan$iih@fridge.shore.net>

Tom Christiansen <tchrist@mox.perl.com> wrote:

: That's correct.  I in fact did not read the part where he
: said he was a Prisoner of $Bill.

But that didn't stop you from flaming him to hell and back when it was
pointed out that your unix-based answer wouldn't work on his platform, did
it?

--Art

--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
            http://www.ziplink.net/~upsetter/ska/calendar.html
--------------------------------------------------------------------------


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

Date: Thu, 11 Jun 1998 19:02:32 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: comp.lang.perl.(n|q) another option?
Message-Id: <3580160f.2307838@news.btinternet.com>

On Thu, 11 Jun 1998 13:15:14 GMT, John Porter wrote :

>Tom Christiansen wrote:
>> 
>> The pods get [to] be grepped!
>
>Now everyone, grep your pod, and we'll begin...
>

A ho down nice one.

(or should that be a hose down ?)

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Thu, 11 Jun 1998 19:02:30 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: create RTF file on the fly?
Message-Id: <3580127c.1393007@news.btinternet.com>

On Thu, 11 Jun 1998 14:48:32 +0100, Richard G. Coleman wrote :

>Hi
>
>Does anyone know of a way (or a program) to create an RTF file or other
>readable document from form entries.  It should be able to create tables
>in the document.  
>

Not personally (I have never wanted to) but:

On 27 May 1998 13:10:34 GMT, David A Thomas wrote :

>Leon Shaigorodsky (LeonS@amdocs.com) wrote:
>> How can i convert predefined text file to RTF format.
>> Or how can i make RTF file (what is the specification of it)
>> May be some package already exist ?
>
>The spec for RTF can be found at
>http://www.sunpack.com/RTF/RTF114.htm

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 11 Jun 1998 19:03:33 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Document contains no data?
Message-Id: <6lp9m5$gqq@fridge.shore.net>

Dave Barnett <barnett@houston.Geco-Prakla.slb.com> wrote:
: Dom Franco wrote:
:> 
:> I recently downloaded and installed the Omnihttpd server on my
:> computer.  When I try to run simple Perl scripts locally I get the
:> message "Document contains no data."  What does this mean?
:> Thanks

: More than likely, you failed to put something like this before any other
: code that prints information:
: print "Content-type: text/html\n\n";

I've seen two people post this in this thread. If you leave the
Content-type header off, you'll get a server error message, not a blank
document. "Document Contains No Data" usually means that the script made
it through the interpreter, emitted the content-type header, and *then*
died before it printed anything else.

For the original poster, try throwing some print statements into your code
to figure out where it's crapping out.

--Art

--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
            http://www.ziplink.net/~upsetter/ska/calendar.html
--------------------------------------------------------------------------


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

Date: Thu, 11 Jun 1998 19:56:50 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Domino 4.6 on NT 4 -- what perl for CGI's?
Message-Id: <358030f1.8954203@news.btinternet.com>

On Thu, 11 Jun 1998 14:37:29 -0400, Douglas White wrote :

>I'm running Domino 4.6 on NT4, and some folks want some perl CGIs.
>Any suggestions about where I should pick up perl for NT?

You should propably look at :
  
   http://www.perl.com/latest.html

Whilst there are two distinct Win32 distributions the one preferred by
more cats er people is the so-called "standard" distribution by
Gurasamy Sarathay which is based on a later revision and has a more
complete set of modules.  If you are using Domino then the dubious
advantage that the ActiveState port has in running ISAPI for some
people will be of no interest to you.
 
A FAQ for Win32 Perl can be found at:

    http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html

Which is useful in adjunct to the standard perlfaq.

> Anyone done this and have any warnings they'd like to pass on?
>

Learn about the Quirk and Irks of NT.  It may look easy to use (to
those who like that sort of thing) but it certainly doesnt seem that
it was designed to be nice for developers to work with (to make
perhaps but thats another story ).

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Thu, 11 Jun 1998 19:22:48 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Eval questions.
Message-Id: <EuEJ60.Cqz@news.boeing.com>

In article <01bd955c$6c1e5920$02521e0a@tschai>,
John Bokma <john@castleamber.com> wrote:
>
>
>  [ omitted... ]
>
>I've only added the snippets to make clear what I mean.
>They are not a program and hence can't be used the way
>you tried it. To err is human. Besides, the question isn't
>about the code not working, it is about how I can add
>functionality. With regarding to your waste of time and
>energy, it seems you have too much time and energy,
>but are not capable of answering my question. So stay
>out of this thread.
>

That's totally disingenuous. Here's a direct quote from 
your post:

    I have this already working using:

    s/\\([^\\]+\\/ eval $1 ./ meg;"


That has 2 syntax errors which I cited in an attempt to 
help. If you're going to post, please ensure that you
post accurately.

I won't waste any futher bandwidth on this subject.

--
Charles DeRykus


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

Date: Thu, 11 Jun 1998 19:02:34 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Having problems locating a bug!  Can anyone help? - di.txt (1/1)
Message-Id: <35802278.5370511@news.btinternet.com>

On Thu, 11 Jun 1998 01:22:37 GMT, Chris Reynolds wrote :

>begin 644 di.txt
>M(R$O<'5B;&EC+V)I;B]P97)L("UW#0H-"@T*9&EE(")<;E5S86=E(#H@)#`@
>M6V1I<F5C=&]R>5TB(&EF("@D(T%21U8@/B`P*3L-"@T*#0HD:6YD970@/2`B
>M("`B.PT*#0IO<&5N("A$25)%0U0L("(D05)'5ELD(T%21U9=(BD@?'P@9&EE
<snip>

Number found where operator expected at crap.pl line 3, near
"M("`B.PT*#0IO<&5N("A$25)%0U0L("(D05)'5"
  (Might be a runaway multi-line '' string starting on line 1)
syntax error at crap.pl line 3, near
"M("`B.PT*#0IO<&5N("A$25)%0U0L("(D05)'5"
Bareword found where operator expected at crap.pl line 3, near "5ELD"
	(Missing operator before ELD?)
Bareword found where operator expected at crap.pl line 3, near "21U9"
	(Missing operator before U9?)
Array found where operator expected at crap.pl line 3, at end of line
String found where operator expected at crap.pl line 5, near
"M>PT*("`@0$1I<CTH*3L-"B`@('"
  (Might be a runaway multi-line '' string starting on line 3)
	(Missing semicolon on previous line?)
Array found where operator expected at crap.pl line 5, at end of line
Scalar found where operator expected at crap.pl line 5, at end of line
	(Missing operator before ?)
Number found where operator expected at crap.pl line 5, near "$:7"
	(Missing operator before 7?)
Scalar found where operator expected at crap.pl line 5, at end of line
	(Missing operator before ?)
Number found where operator expected at crap.pl line 5, near "$%21"
	(Missing operator before 21?)
Bareword found where operator expected at crap.pl line 5, near "21U9"
	(Missing operator before U9?)
Execution of crap.pl aborted due to compilation errors.

;-}
Its an oldie but a goodie..
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 11 Jun 1998 14:13:55 -0500
From: Chris Halverson <cdh@CompleteIS.com>
Subject: Re: http protocol
Message-Id: <wpd8cf7nv0.fsf@CompleteIS.com>

bpecorin@mailer.fsu.edu (Breeze Pecorino) writes:

> Barry Margolin (barmar@bbnplanet.com) wrote:
> : This is usually just called "http" in /etc/services files.  And you
> : shouldn't add www-http to inetd.conf unless you're running an HTTP server
> : on your machine and it's designed to be run from inetd.
> 
> I have tried httpd, http, and www-http.  None of them work. 

Then the server is probably running standalone. Look at the last line
of Barry's response. I've got web servers on a dozen machines or so
and none of them have an entry for port 80 as they are all standalone
servers. 

HTTP has been assigned port 80 by IANA, so you can use that as a
default value.

Chris

-- 
Chris D. Halverson                         Complete Internet Solutions
PGP mail accepted, finger for public key   http://www.CompleteIS.com/~cdh/


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

Date: Thu, 11 Jun 1998 14:11:44 -0500
From: "Gabriele R. Fariello" <gabriele@kollwitz.doit.wisc.edu>
Subject: I want threads, threads and more threads!
Message-Id: <Pine.LNX.3.96.980611133721.1263A-100000@kollwitz.doit.wisc.edu>


Yes, I know, I know that asking with "I want" is not a good way to start
but...

BTW:  I have read perlipc, perlfunc, perlfaq5, perlfaq, to name a few. I
have read advances perl programming and the camel book and learning perl
(yes, read, not just skimmed) and I have been left wanting so...

Here's the scoop:

I would like to have treads in a script, but perl does not have any
built-in support for them, so child processes are the closest thing,
right? (someone stop me if I'm whong). Alas, child processes cannot modify
variables in the parent script and well, communication between processes
is very limited so I would like some suggestions before I scrap the whole
15,000 line project and re-do it in in another lang  or some ugly thing
like that.

Here is what I came up with:

1) Open n number of child processes that do something, each with it's
separately associated filehandle (so that STDIN of the child is printed to
a filehandle that the parent has). This I can do, but I do not know which
child will finish first, so in order to optimize this process, I have to
check each file handle to see if there is anything to read, if not skip,
if so, read, reap the child, close the filehandle, and spawn a new child
if need be. And I have to be in a loop while doing this, so the main
process is forced to stay in a loop until all the children die. I don't
like the fact that I have to waste so much processing power on what will
eventually be 5,000+ spawned children, having to check each filehandle
(oh, by the way, I don't spawn 5,000 right away, I do 6 to 12 at a time
and wait for output), and have the main process not do anything else
(which it could be doing) until all the input has been gathered. So I no
like this.

2) Open n number of children and have them all write to one file, use a
sig handler (SIGCHLD) and each time a child finishes, read one line from
the file. Problem: I don't know which child croaked, I just know that one
passed away, and, well, can I be sure that if file output buffering is on,
the children will not stomp all over each other's output in the file (e.g.
at 0 milliseconds child A starts writing and at 1 ms child B does the same
and I end up with "hello whoerllldo" or "hello hello world world" or
something like that?) - (yes I could use flock, I suppose I should, so
scratch that last one, but I'd still like to know). So will wait() reap
the most recently died child, or will it wait for all children? Or is
there a way to know the PID of the process that sent a SIGCHLD?

3) Do a combo of 1 and 2.

4) Something else, better, mo better than what I have been able to come up
with.

In conclusion, HELP! I have nightmares about forgetting semicolons!, but I
digress. Any input is greatly appreceated. Please send flames to
idontwant@to.hear.about.it.



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

Date: Thu, 11 Jun 1998 19:02:36 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: MCNY Express - Your Emergency 911# For Web Development And Technical Needs
Message-Id: <3580234e.5584389@news.btinternet.com>

On Thu, 11 Jun 1998 03:04:54 GMT, Ari Eisinger wrote :

>Stop posting to this group!  This group is for discussion of the C++
>programming language.
>

Sorry? Oh

>Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.java,comp.lang.java.help,comp.lang.perl,comp.lang.perl.misc,...

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 11 Jun 1998 19:07:42 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: MODERATION: Time to Vote
Message-Id: <eli$9806111502@qz.little-neck.ny.us>

John Porter  <jdporter@min.net> wrote:
> Stuart McDow wrote:
> > stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
> > > Tom started this thread.
> > Yeah. And?
> > > Why didn't you tell him the same thing?
> > I'm sure he read my posting.
> Don't be sure.
> tchrist kills all cross-posted articles.

Tom is *responsible* for this crosspost. After following up to a post
from John in this thread, I'd say he has not killfiled it based on
the crosspost. He might now have it killfiled to avoid John, but I
don't know.

Elijah
------
voted


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

Date: Thu, 11 Jun 1998 19:04:02 GMT
From: ruck@netcom.com (John Ruckstuhl)
Subject: network monitoring (perl daemon), should dump data to snmpd?
Message-Id: <ruckEuEIAq.sn@netcom.com>

Is it customary/advisable to have your perl-based daemon (serving
whatever) communicate status information (via UNIX socket?) to a local
snmp agent daemon?  (The snmpd making that info available to some remote
network management software)

If not, how does one typically make their sw friendly to remote
monitoring by network management software -- providing performance and
other statistics on demand via a remote procedure call.

dejanews shows me people homegrowing network service monitors:

    Example of monitoring TCP services with Perl
    1997/03/12 <3326DA03.5546@iaea.org> <P.Gillingwater@iaea.org>

    mon-0.37i - Service Monitoring Daemon
    1998/04/12 <6gr68q$4i0$1@palladium.transmeta.com>
<trockij@transmeta.com>

But they don't leverage off of existing snmpware.
P.Gillingwater says "Later, this will be extended to generate SNMP traps
for our NMS". (i.e. will *directly* talk to NMS)
trockij implements lots of automatic alerts (alpha page, email) instead
of handing off the info to a local snmpd...

So, maybe what I propose isn't sane?

Any guidance will be appreciated.

Maybe there's a perl-based simple contrived example that can
send a message to syslogd and to snmpd, too?

A pointer into the fine manuals would be helpful too, if you think
that's
more effective -- I've got 2nd ed of Camel & LLama, and "How To Manage
Your Network Using SNMP" by Rose & McCloghrie at my fingertips, and I'm
a click away from amazon.com.

Thanks,
John Ruckstuhl

-- 
John Ruckstuhl                      ruck@netcom.com


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

Date: 11 Jun 1998 19:29:41 GMT
From: tph@longhorn.uucp (Tom Harrington)
Subject: Re: Opening Files
Message-Id: <6lpb75$66n6@eccws1.dearborn.ford.com>

F.Quednau (quednauf@nortel.co.uk) wrote:
: ted wrote:
: > 
: > How would I open and read all the files in a folder without
: > naming the files in my script? I'm working with Macperl.

<snip>

: It took me 1 minute to answer your question, but almost 30 minutes to get the
: conditional right. I know, this is not a Perl question, but why are the
: following two conditionals not equivalent? Let me answer this myself...

: if ($file ne "." || $file ne "..")

OTOH, this would work:

  if($file ne "." && $file ne "..") 

As it happens, Ted doesn't even need the conditional, as long as
he confines the script to MacPerl.  Macs don't have the Unix "."
and ".." (though I believe that Perl functions like chdir have been
hacked to interpret them properly).  It won't hurt to leave them 
in, though, since I don't think you can legally use either of those 
as filenames on a Mac.


--
Tom Harrington --------- tph@rmii.com -------- http://rainbow.rmii.com/~tph
       "UN-altered REPRODUCTION and DISSEMINATION of this IMPORTANT
               information is ENCOURAGED" -Robert McElwaine
Cookie's Revenge: ftp://ftp.rmi.net/pub2/tph/cookie/cookies-revenge.sit.hqx


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

Date: Thu, 11 Jun 1998 14:32:34 -0500
From: Deva Seetharam <devs@usa.net>
Subject: Re: Passing variables from bourne script to perl script
Message-Id: <358030D1.E9A0E803@usa.net>



Mark Fergusson wrote:

> Hello,
>
> I have a boune shell script which contains a number of variables (about
> 20). Some of these varaiables contain a long sentence. I need to run a
> perl script from here and pass these variables to the perl script.
>
> Eg.
>
> #script1
> !#/bin/sh
> variable1="this is a long sentence which can contain *:()&^% etc"
> variable2="test"
>
> #run perl script
> ./script2
>
> when I run ./script1
> perl script (script2) needs to set $variable1 and $variable2 as above.
>
> #!/usr/local/bin/perl
> # variable1 & variable2 set as in script1
> # <help here>
> $variable1="this is a long sentence which can contain *:()&^% etc";
> $variable2="test";
>
> Any comments will be appreciated.
>
> Thanks.
> --

If u can create ur own FS sequence, which is improbable to
appear in the actual data
$variable1 = "this!@#is!@#long!@#"
then you can pass this value as a command line string.

In perlscript, it can be revived to its original form.

@args = @ARGV;

foreach $arg (@args)
{
    $arg =~ s/!@#/ /g;  #" " replaces our FS.
}Hope this helps.

> _____________________________________________
> Mark Fergusson: mferg@hal.ddntl.didata.co.za
> Dimension Data:
> PO Box 236, Pavillion, 3611, South Africa
> (+27)-31-204-8424 (Work)
> (+27)-31-204-8590 (Fax)
> 082-771-8519 (Cell)





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

Date: Thu, 11 Jun 1998 14:30:41 -0500
From: "Gabriele R. Fariello" <gabriele@kollwitz.doit.wisc.edu>
To: Tu-Thach <tuthach@argo.unm.edu>
Subject: Re: PASV
Message-Id: <Pine.LNX.3.96.980611142522.1263D-100000@kollwitz.doit.wisc.edu>

On 11 Jun 1998, Tu-Thach wrote:

> I wrote a PERL program to ftp to my host and get a file.  I can login and
> everything.  but after that, my code looks
> print MYSOCK "PASV\r\n";
> print MYSOCK "RETR $filename\r\n";
> and the output prints "Entering Passive Mode (bunch of numbers)"
> and halts there forever.  Am I doing something wrong?  Or missing
> something?
> 
> Thanks
> 
> 

Have you tried using Net::FTP instead of implementing your own version? I
use it for exactly what you are doing (among other things) and so far it
has worked well on Linux, AIX, BSDI, and Solaris (have not tried on
Win32). It's a must of anyone doing net stuff. Get the Net, HTTP, LWP libs
from CPAN. (Some need to be installed before others to get full
functionality) but with perl 5.004_04 I have installed

Data-Dumper-2.081.readme
Data-Dumper-2.081.tar.gz
HTML-Parser-2.17.readme
HTML-Parser-2.17.tar.gz
MD5-1.7.readme
MD5-1.7.tar.gz
MIME-Base64-2.05.readme
MIME-Base64-2.05.tar.gz
libnet-1.0605.readme
libnet-1.0605.tar.gz
libwww-perl-5.33.readme
libwww-perl-5.33.tar.gz

and it works great for all my TCP/IP needs.

-Gabriele



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

Date: Thu, 11 Jun 1998 19:06:48 GMT
From: Greg Hersh <ghersh@bbnplanet.com>
Subject: question on a process mgmt (how to kill a child process without creating zombie)
Message-Id: <35802AB4.212E@bbnplanet.com>

I have a situation where I have to fork multiple child processes but
if any of those haven't finished in say 10 minutes, kill them.
Then start the whole thing again, and again, and again ...

A script (Perl 5.004) forks the processes, saves pid of each, 
goes to sleep for 10 minutes, wakes up, then waitpid with WNOHANG
option and issues kill 9 $pid if return status = 0.
 Unfortunately if child does get killed, this creates a zombie
processes. After a while I got quite a few of them. Is there any
way to terminate the child without creating a zombie?

(a child is written in C which I would rather not change)

(a script runs on Solaris 2.5)

Thanks,


-- 
Greg


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

Date: 11 Jun 1998 19:22:24 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Return characters from a string
Message-Id: <6lpapg$26q@news-central.tiac.net>

In article <6lou2h$j6a5@eccws1.dearborn.ford.com>,
Tom Harrington <tph@rmi.net> wrote:

>: Not weird, just slow.  Very slow.  TMTOWTDI, but they're not all "created 
>: equal."
>
>Thanks, I had no idea.  The regexp approach "felt" better, but if it's
>that much slower then I need to adjust my attitude a bit.

This kind of thing is a matter of balance, if you only do the operation
once in a program then the real difference (3 or 4 seconds difference for
65000+ iterations) isn't really that much compared to the cost of starting
the interpreter - then you can stick with the thing you feel best
expresses what you want to do a human audience.

Benchmarking's always interesting and if you're trying to tune up some
critical section then it's invaluable.

One thing to keep in mind with regexes is that it's possible to write
expressions which can take a long time to run...

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Thu, 11 Jun 1998 12:36:33 -0700
From: Scott Bronson <sbronson@opentv.com>
Subject: Re: Stages in a pipeline
Message-Id: <358031C1.D19B94D9@opentv.com>

Jim Bowlin, Zhang Zhengyu:

>  print format_lists number_lines remove_header get paragraph @my_text;

Unfortunately, this method requires reading the entire file all at
once.  Doable, but considering the sizes of the files, I'd prefer to
avoid this.


You're a naughty, naughty, naughty and very clever boy Tom...  (to
paraphrase Bloom County}

>  (ftroop)    return if $pid = open(STDOUT, "|-");

Unfortunately, the pipe between each stage means that I have to print
and then re-parse to move data between each stage.  Doable, but I think
that's making the computer work harder than it should.


I ended up rolling my own solution, similar to what Jaime Metcher
described.  I'm open to any comments.

Basically, I put all stages in a hash of anonymous function references. 
Key is a reference to each stage, value is the next stage up the pipe
(i.e. the function that stage should call to get its input).

Here's an example of perhaps the simplest stage in the pipe.


sub stage_running_header_remover
{
    my $get_par = ( $pipeline{\&stage_running_header_remover}
        or die "Pipe can't leave stage_running_header_remover, bailed"
);

    my @par;
    do {
        @par = &$get_par();
    } while( (scalar(@par) == 2 || scalar(@par) == 3) && $par[1] eq "\f"
);
    
    return @par;
}



And this is how I set the pipeline up...  (eventually, @pipe will be
generated at run-time and passed to prepare_pipe as an argument).


sub prepare_pipe
{
	# dumper calls modules which calls text_reformatter which calls etc.
	my @pipe = (
				\&stage_paragrapher,
				\&stage_running_header_remover,
				\&stage_html_escaper,
				\&stage_text_reformatter,
				\&stage_modules,
				\&dumper,
				);

	# create the pipe hash from the list of modules.
	undef %pipeline;
	for $i ( 0 .. $#pipe-1 ) {
		$pipeline{$pipe[$i+1]} = $pipe[$i];
	}

	# return the pipe's entrypoint
	return $pipe[$#pipe];
}


# fire up the pipeline...
$p = prepare_pipe();
&$p();


Thanks for all the prompt and excellent replies!  I learned from each of
them.

	- Scott


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

Date: Thu, 11 Jun 1998 21:54:15 +0200
From: Urs Martini <martini@okay.net>
Subject: Suche ein Perl Buch
Message-Id: <358035E7.4F40365C@okay.net>

Hi!

Ich bin auf der Suche nach einem Perl Buch das f|r Anfdnger verstdndlich 
aber auch f|r Fortgeschrittene nicht uninteressant ist.
Kann mir da jemand hefen?

cu
-- 
Urs Martini (urs.martini@gmx.net)
ICQ: 8240894 (Friedel)
http://come.to/urs
http://fly.to/horizonte


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

Date: 11 Jun 1998 19:30:29 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Using SDBM and Hashes of Hashes. Is it possible? How?
Message-Id: <6lpb8l$26q@news-central.tiac.net>

In article <35800113.EFA35BF2@dkstat.com>, jp  <jp@dkstat.com> wrote:

>I'm trying to use SBDM to store Hashes of Hashes. Is this possible?

You might want to look on CPAN (the comprehensive perl archive network)
for the MLDBM package.  Its readme is at

http://www.perl.com/CPAN-local//modules/by-module/MLDBM/MLDBM-2.00.readme

anongst other places.

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2844
**************************************

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