[6594] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 219 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 2 07:07:14 1997

Date: Wed, 2 Apr 97 04:00:26 -0800
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, 2 Apr 1997     Volume: 8 Number: 219

Today's topics:
     Re: 5.004beta and $& (Eric Bohlman)
     are there Comm.pl usage examples <shlomoa@iil.intel.com>
     Can't get 2 way communication using sockets <tarcher@csu.edu.au>
     Re: Common Blocks in text files (Eric Bohlman)
     Could some one please help <alastair@redboxad.demon.co.uk>
     Re: db_file, hash and segv <armin.faltl@siemens.at>
     DBI.pm question <cbusch@member.com>
     Re: Does perl have constants? <tchrist@mox.perl.com>
     Filter: Latex to SGML problem (regular expressions) <cie95aol@lustudat.student.lu.se>
     Form post to Sendmail fails (Jonny Golden Bollocks)
     Re: gethostbyaddr ? (Eric Bohlman)
     Re: Log base 10 <shlomoa@iil.intel.com>
     Re: Multiplication9s (Eric Bohlman)
     Re: New Microsoft Perl Product (fwd) (Jamie O'Shaughnessy)
     Perl Alpha Compiler (Dan Ascheman)
     Perl class <jeffhen@concentric.net>
     Re: Perl hourly fees? <tchrist@mox.perl.com>
     Re: Perl Mail Parser Question <anirvan@crl.com>
     Re: perl5-cgiscript (Eric Bohlman)
     Perl502 on Os/2? - How? (Dan Ascheman)
     Re: perlref-5.001.2 vs perl 5.004? (Johan Vromans)
     Re: POD: Style Guide or Module Template Available? (Steven W McDougall)
     Porting Perl to C  (Help with) (Dan Ascheman)
     Re: Replaceing Text (Ted Yee)
     Re: Starting, Suspending, and Restarting a Child <armin.faltl@siemens.at>
     Re: String substitution problem (David Alan Black)
     Re: substituting with /g and simulating "lookbehind" (Outi Lehtinen)
     Trees: is there a perl module? lpa@sysdeco.no
     Re: Unix and ease of use (WAS: Who makes more ...) <seay@absyss.fr>
     Re: Unix and ease of use (WAS: Who makes more ...) <seay@absyss.fr>
     Re: Unix and ease of use (WAS: Who makes more ...) (Eric Bohlman)
     Re: visit my first CGI/PERL project <yemoja@speakeasy.org>
     Wanted, a currency converter? Automatic file download? <robert@chalmers.com.au>
     Re: Who makes more $$ - Windows vs. Unix programmers? <sapa@hq.icb.chel.su>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 2 Apr 1997 09:48:35 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: 5.004beta and $&
Message-Id: <ebohlmanE808Kz.HAC@netcom.com>

Igal Iancu (iancu@iil.intel.com) wrote:
: while ($string =~ /0/g) {
: 	$found++;
: }

[snip]

: foreach ($string =~ /0/g) {
: 	$found++;
: }

[snip]

: I would like to know why "foreach" is twice as slow 
: as "while", even in 5.003)

Just a guess, but in the "while" case the pattern-binding operation is 
being evaluated in scalar context, whereas it's being evaluated in list 
context in the "foreach" case.  I'd imagine that list-context evaluation 
has more overhead than scalar-context evaluation (not to mention the 
repeated assignment of a null list to $_).



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

Date: Wed, 02 Apr 1997 13:48:37 +0300
From: Shlomo Anglister <shlomoa@iil.intel.com>
Subject: are there Comm.pl usage examples
Message-Id: <33423985.36A6@iil.intel.com>

-- 
Shlomo Anglister
IDC ATHENA group       Mail stop : IDC-4C
Phone: 972-4-8230835 ( Home  ) 972-4-8656056 ( Intel )
http://www.iil.intel.com/~shlomoa


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

Date: Thu, 27 Mar 1997 09:05:48 +1000
From: Tim Archer <tarcher@csu.edu.au>
Subject: Can't get 2 way communication using sockets
Message-Id: <3339ABCC.3331@csu.edu.au>

I am trying to a get a conversation going between a client and
server using sockets. I can get the server to write to the client or
the client to the server but when I try and do something like this:

[Server]
print CLIENT "How are you";
$in = <CLIENT>;

[Client]
$in = <SERVER>;
print SERVER "I'm Good thankyou!";

Things just seem to hang. Am I creating a deadlock here?
I'm new to sockets programming, both the client and server are taken
from code in ch6 of the Camel Book 2nd Ed. I'm running perl 5.002 on
Solaris 2.5. It seems logical to me that the above should work but
apparently not. I'm using Unix domain sockets and a non-threaded
server.

Matthew White
mwhite@csu.edu.au


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

Date: Wed, 2 Apr 1997 10:18:11 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Common Blocks in text files
Message-Id: <ebohlmanE809yB.IG0@netcom.com>

lmsilva@cygnus.lnec.pt wrote:

: I would like to compare two files and find common
: blocks of text between them. When I say common I 
: mean at least 5 lines of text that are the same (
: ignoring case and spaces/tabs). I don't have a clue
: about which blocks are similar.

: I've been trying to use "diff", but it is too much
: info for such a small thing (I've got many files to
: compare).

There's a fair amount of literature on detection of common subsequences; 
you might want to do some Web searching and check some books on algorithms.

There's an obvious brute-force solution (for every group of five
consecutive lines in the first file, test it against every group of five
consecutive lines in the second file), but it's going to be slow because
its run time is proportional to the product of the numbers of lines in the
two files.  If your files are small enough, you may be able to tolerate
this, and you can reduce the proportionality constant by doing some
preprocessing on your files (such as calculating checksums on each group
of five consecutive lines in each file and comparing the actual lines only
when the checksums match).

If memory space allows, you could treat each five-line group in the first 
file as a hash key (is there a limit on hash key lengths?), set the 
appropriate hash values, and then check each five-line group in the 
second file against the hash.  This should take time proportional to the 
sum of the number of lines in both files.

Any better algorithms are going to require some knowledge of the 
structure of the two files, such as whether or not identical groups can 
occur multiple times, or whether or not they have to occur in order.



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

Date: Wed, 02 Apr 1997 10:26:12 +0100
From: alastair brown <alastair@redboxad.demon.co.uk>
Subject: Could some one please help
Message-Id: <33422633.6CBF@redboxad.demon.co.uk>

Hi 

Please could some one shed some light onto this problem. I'm trying to
return some of the enviroment variables to my script using the following
code

$rem_host = $ENV{REMOTE_HOST}."!";
$rem_add = $ENV{REMOTE_ADDR}."!";
$browser = $ENV{HTTP_USER_AGENT}."!";

And when I run it I get the following error message even though all of
my variables have been returned.  Does anyone know how to turn this
message off.

CGI Error

The specified CGI application misbehaved by not returning a complete set
of HTTP headers. The headers it did return are:


Thanks


Alastair


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

Date: Wed, 02 Apr 1997 09:59:59 -0800
From: Armin Faltl <armin.faltl@siemens.at>
Subject: Re: db_file, hash and segv
Message-Id: <33429E9E.5446@siemens.at>

Peter Lees wrote:
> 
> g'day - i'm having a problem with a hash table generated from
> a db_file database. here is one of the programs:
> 
> #!/usr/local/bin/perl5 -w
> 
> use FileHandle;
> use DB_File;
> use Fcntl;
> 
> $db1 = tie(%DB1,DB_File,"mydb1",O_RDONLY,$DBACCESS_MODE,$DB_HASH) || die($!);
> .......
 
> after about 11000 records, the program aborts with a message: Out of memory!
> this appears to happen on the READ of the database, since commenting out
> the $NEWDB{$key} = $val; had no effect.
> 
> similarly, in another program adding a new key/value to the existing
> database (DB1) caused a segmentation violation (core was dumped).
> i wasn't sure how to examine the corefile, so i have left that for now.
> 
> the system is IRIX 5.3 and IRIX 6.3, db file is 1.85, perl is 5.003.
> 
> the mydb1 file is 8368128 bytes - quite large, but the system has 64MB RAM
> and 238MB swap...
> 
> can anyone suggest what the problem could be?
> 

To my knowledge, Berkely DB has a bug. It occured in our application,
when we used large records. My solution was to switch to GDBM (GNU-DB).
According to the rating in (in the camel book?) its somewhat slower,
BUT IT WORKS!

Hope this helps, Armin


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

Date: Tue, 01 Apr 1997 16:15:33 -0600
From: Chris Busch <cbusch@member.com>
Subject: DBI.pm question
Message-Id: <33418905.3A09@member.com>

Hello,

When accessing SQL databases, I prefer to work with hash tables ie
$acctinfo{username} where username is the column name, rather
than $acctinfo{2}.

I need a function to get the column names from a table.

With MiniSql, one could use the ListFields function or the name array in
the statement handler to get the column names.

With DBI.pm, how do I do that?

--
Chris Busch cbusch@member.com


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

Date: 2 Apr 1997 11:33:17 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Does perl have constants?
Message-Id: <5htg5t$6sr$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Patrick Hayes <Patrick.Hayes.CAP_SESA@renault.fr> writes:
:shields@crosslink.net (Michael Shields) writes:
:> Tom Christiansen  <tchrist@mox.perl.com> wrote:
:> >     *PI = \3.14159.
:> 
:> What are the pros and cons of this vs. `sub PI { 3.14159 }'?
:One con is that the sub form is exportable (in @EXPORT & @EXPORT_OK), while
:the glob form isn't (unfortunateley).

Sure it is -- just export the scalar.

--tom
-- 
	Tom Christiansen	tchrist@alumni.cs.colorado.edu
    Ten years of rejection slips is nature's way of telling you 
    to stop writing.
		    -- R. Geis


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

Date: 2 Apr 1997 11:21:09 GMT
From: "Andreas Olsson" <cie95aol@lustudat.student.lu.se>
Subject: Filter: Latex to SGML problem (regular expressions)
Message-Id: <01bc3f57$f00b2c60$9bd2eb82@Andreas.lu.se>

Hello!

I'm new to Perl and have some questions.
My goal is to make a filter for a specific Latex document my company has,
to SGML (according to the given DTD). I've read about regular expressions
and I'm sure Perl can solve my problem. Please help me.

One of my problems is that Latex only have a start-tag but in SGML I want
both start- and end-tag. An example:

$patt = "text before first\n".
        "\\section{Chapter1}\n".
        "text between first\n".
        "\\section{Chapter2}\n".
        "text between second\n".
        "\\section{Chapter3}\n".
        "text after last"; 

$patt =~ s|\\section(.*)\\section|<chapter>$1</chapter>|gs;

I want $patt to look like below afterwards but it doesn't:

"text before first
<chapter>{Chapter1}.
text between first
</chapter><chapter>{Chapter2}.
text between second
</chapter><chapter>{Chapter3}
text after last</chapter>";

The code above only matches the first and last "\\section" and if I use the
? inside the paranthesis I only get a match for the two first "//section".
How should I write my expression so that it goes through the whole $patt?

Thanks in advance

By the way: if anyone has some experience in writing such filters I would
be more than happy to share some knowledge.

/Andreas Olsson
Sorona Innovation AB, Sweden


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

Date: 2 Apr 1997 10:38:00 GMT
From: Jonathan.J.Forster@lloydsoflondon.co.uk (Jonny Golden Bollocks)
Subject: Form post to Sendmail fails
Message-Id: <5htcu8$av4$1@news02.pt.uk.ibm.net>

I've got a simple form that posts data to a perl script which in turn
sends the data to a user via Sendmail.

The problem is: running the script from a command line as root works fine
but submitting data via a web page fails (the Web server is not running as 
root). I realise that Sendmail is fussy about it's trusted users.

Other than running the webserver as root, is there any way of getting around
this problem?

Cheers



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

Date: Wed, 2 Apr 1997 09:55:40 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: gethostbyaddr ?
Message-Id: <ebohlmanE808ws.HLH@netcom.com>

Matthew D. Healy (Matthew.Healy@yale.edu) wrote:

: #!/usr/local/bin/perl
: while (<STDIN>) {
: $ip_address = $_;
: chop($ip_address);
: print "$ip_address \t";
: @numbers = split(/\./, $ip_address);
: $ip_number = pack("C4", @numbers);
: ($name) = (gethostbyaddr($ip_number, 2))[0];

Just out of curiosity, why did you use this instead of

 $name = gethostbyaddr($ip_number,2);

since gethostbyaddr returns the name if called in scalar context?

: print "$name \n";
: }


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

Date: Wed, 02 Apr 1997 13:53:05 +0300
From: Shlomo Anglister <shlomoa@iil.intel.com>
Subject: Re: Log base 10
Message-Id: <33423A91.2DDA@iil.intel.com>

I liked the answer
-- 
Shlomo Anglister
IDC ATHENA group       Mail stop : IDC-4C
Phone: 972-4-8230835 ( Home  ) 972-4-8656056 ( Intel )
http://www.iil.intel.com/~shlomoa


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

Date: Wed, 2 Apr 1997 11:14:06 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Multiplication9s
Message-Id: <ebohlmanE80CJJ.KE3@netcom.com>

Steven Sajous (steve@golf.com) wrote:
: Is there a way to keep this freom happening?

: $value =19.95;
: $number = 1;

: $total = $value * $number

: I get $total = 19.950000000000000698

That's simply a consequence of the fact that in any number base, some 
fractions can't be represented exactly in a finite number of digits.  For 
example, in decimal 1/3 is 0.3333333...  Computers represent numbers in 
binary, and some fractions that don't repeat in decimal do repeat in 
binary (and vice versa).

If you need to print numbers, use printf or sprintf, which let you 
control the number of decimal places.  If you're manipulating amounts of 
money, it's often a good idea to do all your arithmetic in pennies (or 
whatever the smallest currency unit you're dealing with is) and convert 
to dollars (or pounds, or what have you) only when printing.



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

Date: Wed, 02 Apr 1997 11:53:42 GMT
From: joshaugh@uk.oracle.com (Jamie O'Shaughnessy)
Subject: Re: New Microsoft Perl Product (fwd)
Message-Id: <334348a5.770761484@newshost.us.oracle.com>

On Tue, 1 Apr 1997 16:11:09 GMT, abostick@netcom.com (Alan Bostick) wrote:
      ^^^^^^^^^^^^^
>> MICROSOFT VISUAL PERL++ ADDS ENORMOUS POWER AND EASE OF USE TO A
>> PROGRAMMING FAVORITE.

:)

Jamie

___________________________________________________________________________ 
Jamie O'Shaughnessy                        Work: joshaugh@uk.oracle.com 
Oracle Designer/2000 Forms Generator Team  Home: jamie@thanatar.demon.co.uk 
______________________________________________________  __  __ _  __ .   __ 
Opinions expressed here are my own and not those of... (__)|-</-\(__ |__ -_ 


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

Date: 31 Mar 1997 14:16:35 GMT
From: asched1@medtronic.COM (Dan Ascheman)
Subject: Perl Alpha Compiler
Message-Id: <5hoh03$g44$1@gazette.corp.medtronic.com>

Does anybody know how to use the Perl Alpha compiler in conjuction with
Perl 5.002 OR 5.003 in order to convert a Perl script into C source code??

Thanks,
Dan

--
Dan Ascheman
@medtronic.com
instruments  phone: x4880  Mail Stop: T426


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

Date: Wed, 02 Apr 1997 00:30:32 -0800
From: Jeffrey Henigson <jeffhen@concentric.net>
Subject: Perl class
Message-Id: <33421928.15F1@concentric.net>

I'm taking a class in Perl (my first!) and my teacher requires that we
visit the www.perl.com site to answer a few questions. The site appears
to be down, however, so I thought I might ask them here. If anyone has
answers, please send them to jeffhen@concentric.net  Thanks a bunch!

1) What is one of Larry Wall's favorite books? If you get stuck you
might try asking a Camel for help.

2) What is the TOTAL number of all Perl bugs reported (open, closed, or
otherwise)?

3) How many Alien Ports of Perl are listed ar CPAN? (How many operating
systems does Pel run on?) What are they?

That's all for now!


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

Date: 2 Apr 1997 11:32:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl hourly fees?
Message-Id: <5htg3j$6sp$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    claird@Starbase.NeoSoft.COM (Cameron Laird) writes:
:Isn't there a schedule written by one of the triumvirate that
:categorizes something like

It had nothing to do with money, and was a take-off on the
old Unix hierarchy.  I do't believe I have it anymore

--tom
-- 
	Tom Christiansen	tchrist@alumni.cs.colorado.edu
    The only disadvantage I see is that it would force everyone to get Perl.
    Horrors.  :-)
                    --Larry Wall in  <8854@jpl-devvax.JPL.NASA.GOV>


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

Date: 2 Apr 1997 06:52:26 GMT
From: Anirvan Chatterjee <anirvan@crl.com>
Subject: Re: Perl Mail Parser Question
Message-Id: <5hsvna$ajs@nexp.crl.com>

-----BEGIN PGP SIGNED MESSAGE-----

Luigi Mattera <mattera@ssga.ssb.com> wrote:
:   I've been trying write a mail parser for Perl on a unix system.  It
: simply has to filter out the subject and body of the message.  I can
: get the subject using a simple /Subject: / search.  I can possibly
: catch the body for a single message, but how to do it over multiple
: messages has me stumped beyond belief.

I've found that mbox style unix mailboxes generally have /^From\s+/ at
the beginning of every message. You can use this fact to tailor your
script accordingly, to skip to the next message when either /^From\s+/
or eof is reached.

_______________________________________________________________
Anirvan Chatterjee . anirvan@crl.com . <URL:http://www.mx.org/>
PGP 0x93C5C165 . finger for PGP/geek . encrypted mail preferred
http://www.mx.org/bookfinder/ : online book comparison shopping 

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBM0ICHGTQ0LuTxcFlAQHwCwQAn3Bt/0HE+PGT6Y8YeJBiFV7WEMxGXLer
SuqabTBXYk9Lcgu7zs1ktPzATNp1Vm8A/5N/1FZULtXpz1JCUvm35VMvvA0eSxH2
Cpd3UrulhiHsVbZL+0ziAg1XWAa58rJzgS2Bpz76LCs5J79v/+lAG2PGyeAMs7Vn
Vh39/sKh51s=
=2kyf
-----END PGP SIGNATURE-----


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

Date: Wed, 2 Apr 1997 11:18:13 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: perl5-cgiscript
Message-Id: <ebohlmanE80CqD.KLn@netcom.com>

[since this is an HTML question and not a perl question, followups have 
been redirected to comp.infosystems.www.authoring.html *only*.  
comp.lang.perl.misc is a fairly high-traffic group, so it *really* helps 
if people post only perl questions there.]

Shoaib Qureshi (shoaibqureshi@worldnet.att.net) wrote:

: i have created an html voting form using radio buttons for the user to 
: click in there respective choice. upon completion of the clicks, the 
: user clicks on the submit button...and yes i need help to fill in the 
: ...

: 1) will i need to use hidden fields to save the variable state 
: information?

Only if it's a multi-page form.

: 2) if so, can i use buttons and hidden fields at the same time?

Yes.

: 3) if not, what is the alternative or a way around this?

Not applicable.



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

Date: 1 Apr 1997 16:02:29 GMT
From: asched1@medtronic.COM (Dan Ascheman)
Subject: Perl502 on Os/2? - How?
Message-Id: <5hrbil$7kv$1@gazette.corp.medtronic.com>

that's my question - How do you compile/build Perl502b.zip on OS/2?
I also need to use the Alpha compiler.  I have compiled Perl5.3 with the 
Alpha compiler on UNIX, and successfully converted a Perl script into C
code
and then into a C executable - I need to do the same on OS/2 - Anyone know
how?  I have everything I need, but how to you install Perl on OS/2 with
patches?

-Dan

--
Dan Ascheman
@medtronic.com
instruments  phone: x4880  Mail Stop: T426


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

Date: 02 Apr 1997 12:04:51 +0200
From: JVromans@Squirrel.NL (Johan Vromans)
Subject: Re: perlref-5.001.2 vs perl 5.004?
Message-Id: <wl39131viyk.fsf@plume.nl.compuware.com>

lvirden@cas.org writes:

> Has anyone looked at the changes in Perl 5.001 thru 5.004beta to see
> what, if any, changes are needed in the perlref document?

It's usually best to ask the author :-).

I have an updated the reference guide to 5.004 alpha and I will
complete it after the 5.004 release (too many things are still
changing).

Most changes are in the 5.003 version, that is also published by
O'Reilly <http://www.ora.com/catalog/perlqr/>. When you order it, ASK
FOR THE REPRINTED EDITION (with the Cyan cover).

-- Johan


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

Date: Wed, 2 Apr 1997 08:23:45 GMT
From: swmcd@world.std.com (Steven W McDougall)
Subject: Re: POD: Style Guide or Module Template Available?
Message-Id: <E804nL.G8K@world.std.com>

Bill Cowan <billc@tibinc.com> writes:

>I have read man pages for perlpod and perlsyn regarding POD directives
>(=head1, =item, etc.).  Also checked dejanews for "POD template" and
>"POD style" without luck.  For a new project, I want to have standard or
>guidelines for POD embedded in the Perl program.  

>Does anyone have any suggestions or pointers? 
>What to do and not to do?
>Standard template or skeleton of doc sections?  

Take a look at

http://world.std.com/~swmcd/steven/Perl/

- SWM


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

Date: 28 Mar 1997 14:11:54 GMT
From: asched1@medtronic.COM (Dan Ascheman)
Subject: Porting Perl to C  (Help with)
Message-Id: <5hgjja$hjm$1@gazette.corp.medtronic.com>

hello all,
  I have a question concering a Perl to C conversion...I have been told
that the only thing that will do a conversion from Perl to C code is the
Perl Alpha compiler....Is that true?
I am running SunOS and OS/2 - Is one better than the other for what I want
to do?  I am going to attempt using the Alpha compiler today to see if it
works - but does anyone else have any suggestions??

Thanks,
Dan

--
Dan Ascheman
@medtronic.com
instruments  phone: x4880  Mail Stop: T426


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

Date: Wed, 02 Apr 1997 10:48:04 GMT
From: ted@qp.com (Ted Yee)
Subject: Re: Replaceing Text
Message-Id: <33423837.1790521@nntp.netcruiser>

On 31 Mar 1997 21:59:53 GMT, "Stephen Hill" <scs@huron.net> wrote:

>When I use the sniplet of script below it converts the text to all lower
>case, this is not what I want. I wish the text to have the same cases as
>before the manipulation. If the original word started with a capital I want
>the manipulated text to start with a capital..
>
>If you have any ideas please email me at scs@huron.net
>
>
>@lines[$i] =~s/@keywords[0]/<I>@keywords[0]<\/I>/;

Try this:

@lines[$i] =~s/(@keywords[0])/<I>$1<\/I>/i;

The $1, $2, $3 etc match the first, second, third patterns that are
contained in brackets.

I'm assuming that case doesn't matter as the capitalization problem
you mentioned only applies if the "i" option is used.



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

Date: Wed, 02 Apr 1997 10:33:45 -0800
From: Armin Faltl <armin.faltl@siemens.at>
Subject: Re: Starting, Suspending, and Restarting a Child
Message-Id: <3342A689.5F01@siemens.at>

Clark Dorman wrote:
> 
> I am working on a client / server application that is supposed to
> spread runs of a large simulation around our local network.  Each run
> of this large program takes a while to complete.  If system load gets
> too high (because someone is doing something), I want to be able to
> suspend the run until load drops below a certain level.  What I have
> now looks like:
> ...... 
> The problem is that I don't know how to start the job in such a way
> that I can suspend it.  Should I fork a child within the client and
> get a pid number, and then I can do a kill to suspend it, and do a
> system "fg $pid" to continue it?

I think its better to do the following:

# install signal handler for SIGCHLD
# that resets $ChldRunning

$pid = fork;
if ($pid > 0) { # parent
	$ChldRunning = 1;
	$chldActive  = 1;
	while ($ChldRunning) {
		# check load
		if ($loadToHigh) {
			kill $SIGSTOP $pid if $chldActive;
			$chldActive = 0;
		} else {
			kill $SIGCONT $pid if !$chldActive;
			$chldActive = 1;
		}
		# waite a while
	}		
} elsif ($pid == 0) { # child
	&do_the_work();
} else {
	# fork failed
}

Hope this help,
		Armin


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

Date: 2 Apr 1997 11:28:37 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: String substitution problem
Message-Id: <5htft5$p5f@pirate.shu.edu>

ted@qp.com (Ted Yee) writes:

>Here's my problem:

>I have a string substitution where sometimes, some extra text in the
>replacement term will conflict with the matching term.

>ie.

>$string = "this is a test";
>$term = "is";

>$string =~ s/$term/replace with this/gi;

>The problem is that with the above example, the resulting output is:

>threplace with this replace with threplace with threplace with this a
>test

I can't duplicate your error:

candle:~$ perl -w
$string = "this is a test";
$term = "is";
$string =~ s/$term/replace with this/gi;
print "$string\n";
^D
threplace with this replace with this a test

(Perl 5.003_16)

David Black
dblack@icarus.shu.edu



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

Date: 2 Apr 1997 10:41:58 +0300
From: olehtine@cc.helsinki.fi (Outi Lehtinen)
Subject: Re: substituting with /g and simulating "lookbehind"
Message-Id: <5ht2k6$4hb@kontti.Helsinki.FI>


I would use something like 

$string =~ s/(\\{)|{/$1/g

It simply copies all \{'s and strips all {'s from the string.


-Outi
--
Outi.Lehtinen@Domlang.FI


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

Date: Wed, 02 Apr 1997 02:41:07 -0600
From: lpa@sysdeco.no
To: lpa@sysdeco.no
Subject: Trees: is there a perl module?
Message-Id: <859970353.27582@dejanews.com>

Hallo,

 I need to parse a file and produce a tree of objects.
 Is there a module which implements a tree data structure?
 Are there some traps I should be aware of when implementing
 a "node" class (like garbage collection, for ex.)?

Thanx for attention

Luca

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Wed, 02 Apr 1997 09:23:30 +0100
From: Douglas Seay <seay@absyss.fr>
To: Terry Reedy <tjreedy@udel.edu>
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <33422592.3579@absyss.fr>

Terry Reedy wrote:
> 
> In article <33414A13.4D45@absyss.fr>, seay@absyss.fr says...
> > But remember that
> >everytime someone does some form of freeware (GNU,
> >Perl, Linux, whatever), this is a bit of socialism.
> 
> NO!  freeware is voluntary activity (free enterprise) with no guns or
> g-men in sight.  It is the opposite of socialism.

Can't disagree with you more.

I do agree that all forms of socialism/communism/statism
that have been tried involve force, but that isn't part
of the actual theory.  Since theory and practice don't
see eye-to-eye, I'll stick with capitalism because in
practice it does better than socialism.

Maybe I'm just nit-picking details, but you seem to
have gotten mixed up with the definition and the
implementation.  The defintion is great, the actual
implementations suck.

And for what its worth, I see the major problem with
the implementation that the theory doesn't take into
account basic human nature.  Socialism is a great
idea, but ill-dapted for the human race.


- doug

PS - G-men is a reference to "Government Men", namely
J. Edgar Hoover and his FBI.  It is force from a
capitalist power.


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

Date: Wed, 02 Apr 1997 09:38:40 +0100
From: Douglas Seay <seay@absyss.fr>
To: Michael Craft <jsi@idiom.com>
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <33422920.58C3@absyss.fr>

Michael Craft wrote:
> 
> > > Is France a socialist society?
> >
> > Yes, it is.
> 
> France has a stock market, rich people, etc., just like every
> other country.
> 
> (The Socialist Party is not socialist.)

Maybe we have diferent definitions of the idea "socialist".
The French adopted socialism in 1848 (or there abouts)
and haven't really looked back since.  Most european
countries are socialist (some more than others).

Remember that socialism doesn't say "everything belongs
to everybody", that is communism.  Socialism says that
the government (or the people) help everyone irregardless
of details such as social or financial status, how they
got into the situation, whatever.  To achieve this end,
they take the "surplus" resources from the less
unfortunate to help the more unfortunate.

The socialist party is, in fact, socialist.  Every time
Jospin (the current leader of the PS) is on TV, he talks
about how we need to do more (ie-taxes) to help the poor,
the needy and the hungry.  The right (ie-capitalists
such as Chirac and Juppe) talking about how much taxes
are already being consumed helping the poor.  They never
talk about cutting social aide, just lowering taxes
(although everyone can read between the lines).

This is a socialist country with a capitalist-style
economic system.  Not the most elegent system ever
devised, but it usually works.  I assume this is more
or less the same as in other countries in europe.

As I said in another post, the strong-arm tactics that
are associated with socialism are not part of the definition.
Even in the US (a capitalistic country with a few bits
and pieces of socialism), there is force when you don't
contribute to the common good (ie- pay taxes).

- doug


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

Date: Wed, 2 Apr 1997 09:32:51 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <ebohlmanE807ur.GMB@netcom.com>

: I am a capitalist becase I am a (more or less) realist.
: Greed might not be good, but it is present.  Socialism
: doesn't take this into account.  But remember that
: everytime someone does some form of freeware (GNU,
: Perl, Linux, whatever), this is a bit of socialism.
: The world is a better place because of it.

I don't really see the relationship between freeware and socialism, since
the author of freeware makes a free choice to make it publicly available
at no cost; he's not forced to by any state authority.  This is perfectly
consistent with capitalism as defined by Adam Smith (who I consider to be
more of an authority on what capitalism is than Ayn Rand).  Oftentimes
it's in one's own economic interest to choose to make some of one's
creations freely available; to name only one such circumstance, doing so
may make it possible (or at least easier) for someone else to create an
application or utility that has value to you.  Or it may encourage people
to come to you for custom work that they'll pay for. 

Capitalism is not, despite what some people think, based on everyone
trying to maximize their own utility at the expense of others.  Such a
system can't work for very long, since in a group of N people it means
that every person has 1 person trying to maximize his utility and N-1
people trying to minimize it, which usually leads to a decline in the
total utility present in the group.  Rather, it's based on the notion of
everybody trying to maximize the total utility in the group and taking a
share of the increase proportional to the amount one contributed to the
increase (not that this is not the same as the total increase in utility
being divided equally among members of the group).  It's not based on
trying to put your competitors out of business or trying to form
monopolies (note Ricardo's Law of Comparative Cost, which implies that
Social Darwinism is not a necessary condition for, nor an inevitable
consequence of, capitalism).  It is not a "winner take all"  system, and
IMHO the move in the American economy toward winner take all is going to
harm our markets in the long run (because we're a country whose economic
assets lie mostly in adding value to goods or providing services, the
market value of the "all" that the "winners" take will decline if few
people can buy it; the situation would be different in a country with lots
of petroleum or precious minerals). 

Many of what some leftists identify as the inherent features of 
capitalism are actually perversions of capitalism.  It's worth noting 
that *pure* capitalism suffers from many of the same problems as pure 
socialism (mostly stemming from the fact that people do not always act 
rationally), and consequently all "capitalist" societies actually 
practice a modified form of capitalism. 


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

Date: 2 Apr 1997 04:01:42 GMT
From: "Bobo" <yemoja@speakeasy.org>
Subject: Re: visit my first CGI/PERL project
Message-Id: <01bc3f1a$63ce5f20$413bb2cf@alfageek.wolfenet.com>



Ster <ster@stargazer.net> wrote in article
<01bc3ce9$e28d2a40$0a7b65cf@cornholio>...
> I welcome everyone to visit my first CGI/Perl project.  I am welcoming
the
> readers of com.lang.perl & comp.lang.perl.misc because you have helped me
> so much.
Uhhh...none of the buttons are responding to my gentle mouse clicks.  Try
again?

---Chris


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

Date: Wed, 02 Apr 1997 20:07:04 +1000
From: Robert <robert@chalmers.com.au>
Subject: Wanted, a currency converter? Automatic file download?
Message-Id: <33422FC8.6FFA@chalmers.com.au>

Hi,
Does anyone have any currency converter code?
Also, I need a perl script to automatically download a text file every
night?
Thank heaps if anyone can help

cheers,
Bob
-- 
robert@chalmers.com.au	Support Whirled Peas.Sheng huo jiu shi dou zheng
http://www.chalmers.com.au Roberts Bookshop for CIBTC. Amazon.com. Local
Books about China, books from China,         Video and Movies from China 
Business Links in Dalian, and Beijing.                       China Trade


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

Date: Wed, 02 Apr 1997 17:37:02 +0600
From: "Andrew B. Sapozhnikov" <sapa@hq.icb.chel.su>
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <334244DE.59BF5B22@hq.icb.chel.su>

Kirk M. Sigel wrote:
> Good programmers make more than bad ones. :) That's all I need to know.

It's a great mistake! I think what I'm good programmer (without the
excessive modesty :), but I'm make less than the worst one in the USA.
Because I'm live in Russia. And here, I can find a highly payed vacancy
only via acquaintances. I don't know, but to my mind, the same situation
there is in another countries too. Well, it's may be in less extent.

>             Kirk M. Sigel
>          computer programmer
> 607-257-6413   mailto:kmsigel@ksx.com
> fax-257-6834       http://www.ksx.com

			Best regards, Andrew Sapozhnikov.
			sapa@hq.icb.chel.su


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

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

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