[6591] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 216 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 1 19:07:10 1997

Date: Tue, 1 Apr 97 16:00:25 -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           Tue, 1 Apr 1997     Volume: 8 Number: 216

Today's topics:
     "Bad free()" warning, splitting on variable delimiters (Maiko Covington)
     "Bad free()" warning, splitting on variable delimiters (covington maiko)
     Re: \n problem??? compatibility with dos (Tad McClellan)
     Re: Adding REFRESH button to frameset.cgi <blan0416@uidaho.edu>
     Build a RDBS around the pack function. (Gabriel Ramini)
     Data struc. or algor. for multi-type lists (Christopher Lott)
     Re: Functions and operators <vladimir@cs.ualberta.ca>
     How to declare (or my) a $$var variable? (Wing Choy)
     Re: Log base 10 (Phil Hanna)
     Re: New Microsoft Perl Product (fwd) (Tad McClellan)
     Re: Perl mishandles some multidimensional array referen < hansm@icgned.nl>
     Re: Perl script for UNIX mail to produce web page? (Michael Fuhr)
     repeating statements in a chat <blan0416@uidaho.edu>
     Re: repeating statements in a chat (Nathan V. Patwardhan)
     Starting, Suspending, and Restarting a Child <dorman@s3i.com.anti-spam>
     Re: String substitution question <74331.3261@CompuServe.COM>
     Re: substituting with /g and simulating "lookbehind" (Tad McClellan)
     Re: Wrapping text in perl <ltorres@campus.ruv.itesm.mx>
     Re: Writing a routine the works like 'open' (Dave Mencin)
     Re: Writing a routine the works like 'open' (Bernard Cosell)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 1 Apr 97 21:47:44 GMT
From: maiko@geisel.csl.uiuc.edu (Maiko Covington)
Subject: "Bad free()" warning, splitting on variable delimiters
Message-Id: <maiko.859931264@geisel.csl.uiuc.edu>

Hello.

	I have a question regarding the warning message "Bad free()".

THE SHORT VERSION:

I'm getting an error message in a CGI script involving splitting some
strings up into arrays based on a variable delimiter (for more details,
check out the long version):

	"Bad free() ignored at YourFile.pm line 205."

This is from the underlying C, yes? My main question to help with debugging
it right now is, does anyone know exactly what "Bad free()" is warning OF?
Is it trying to free something that wasn't malloc'ed, or free something
twice, or? If it helps any, the code still WORKS - I just get this ugly
warning message printing in the middle of the page.

THE LONG, TEDIOUS VERSION:

	I have some code which needs to compare a list of items typed
in by a user with some lists of items stored in a file. The idea is, foreach
of the user's items, I'd like to check if that item is a variant of some
item in the filed list.

	In the answer file, the master list consists of several lines,
where each line has a comma separated list of variants. If I wanted a list
of states beginning with "I", it would be something like this:

	Illinois,IL
	Indiana,IN
	Idaho,ID
	Iowa,IA

The user's list is a single line separated by commas, like this:

	Illinois, Idaho, Indiana, Kansas 

What happens is, the user's list is read in, and split on commas into an
array @user_list. The real answers are read in one line at a time, split
on commas into arrays @master_line, then the references to the @master_line
arrays are pushed into a single array @master_list.

To do the checking, there is a loop:
	
        CHECK_A_USER_ANSWER:
	foreach $item (@user_list) {
           make an array of simple permutations of it 
              (messed up capitalization, etc).
           foreach $master_line (@master_list) {
              foreach $solution (@$master_line) {
                 make the same kind of array of simple permutations of THIS
                 compare the two, and record if anything matched, etc.
                 if something DOES match, they got it right so..
		 next CHECK_A_USER_ANSWER;
              } 
           }
	}

This all worked fine, and things were happy. Until... someone decided that
it would be a nice idea for the users to be able to list their states with
something besides a comma as the delimiter between items, if they wanted.
The master answers in the answer file would be listed as always, with commas,
but now, in a separate place (which doesn't matter here) the variable
$separator would be set to some character to be used to split the user's
answer on.

	So now, instead of

	my @user_list = split(/,/,$user_list_string);  we have
	my @user_list = split(/$separator/o,$user_list_string);

All of a sudden, with ONLY this change, I get the warning 

	"Bad free() ignored at YourFile.pm line 205."
	
It's only a warning. The code still works. But, as it's a CGI, having this
appear on the screen is generally Not a Good Thing. 

Line 205 is right after the subroutine call 
   $solution_array_ref = $self->make_array($solution);

which makes the array of simple permutations (all lowercase to ignore bad
capitalization, etc) of the good answer (which is an element of the 
@master_line array). I don't get the error when I call the SAME subroutine
on elements of the @user_list.

Also I only get the error for the SECOND (and subsequent) iterations of the
outer loop (CHECK_A_USER_ANSWER), when I call the subroutine on the real 
answer (the item from @master_line): 

   called it on a user answer in the outer loop: OK
   called it on a real answer in the inner loop, bunch of times: OK
   called it on a user answer in the outer loop, second iteration: OK
   called it on a real answer in the inner loop, first time: WARNING!
   called it on a real answer in the inner loop, more times: OK
   called it on a user answer in the outer loop, third iteration: OK
   called it on a real answer in the inner loop, first time: WARNING!
 ... and so on.

	I'm confused why it complains when I'm calling it for the @master_line
real answers, as those are still gotten from a split on a comma as before.
It's ONLY the splitting of the user's string into @user_list that changed.
Does splitting on the variable delimiter "change" the character of the
list somehow? Even so, I'm getting the error when I try to do things with
an item taken from that list.

	The warning is, again,

	"Bad free() ignored at YourFile.pm line 205."

This is from the underlying C, yes? My main question to help with debugging
it right now is, does anyone know exactly what "Bad free()" is warning OF?
Is it trying to free something that wasn't malloc'ed, or free something
twice, or?

	Much thanks for any hints anyone might be able to provide.

	Maiko Covington (maiko@yertle.csl.uiuc.edu)




-- 
-----
Maiko Covington
Mallard Project
maiko@yertle.csl.uiuc.edu


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

Date: 1 Apr 1997 21:56:00 GMT
From: mcovingt@coewl.cen.uiuc.edu (covington maiko)
Subject: "Bad free()" warning, splitting on variable delimiters
Message-Id: <5hs09g$3ah@vixen.cso.uiuc.edu>


Hello.

	I have a question regarding the warning message "Bad free()".

THE SHORT VERSION:

I'm getting an error message in a CGI script involving splitting some
strings up into arrays based on a variable delimiter (for more details,
check out the long version):

	"Bad free() ignored at YourFile.pm line 205."

This is from the underlying C, yes? My main question to help with debugging
it right now is, does anyone know exactly what "Bad free()" is warning OF?
Is it trying to free something that wasn't malloc'ed, or free something
twice, or? If it helps any, the code still WORKS - I just get this ugly
warning message printing in the middle of the page.

THE LONG, TEDIOUS VERSION:

	I have some code which needs to compare a list of items typed
in by a user with some lists of items stored in a file. The idea is, foreach
of the user's items, I'd like to check if that item is a variant of some
item in the filed list.

	In the answer file, the master list consists of several lines,
where each line has a comma separated list of variants. If I wanted a list
of states beginning with "I", it would be something like this:

	Illinois,IL
	Indiana,IN
	Idaho,ID
	Iowa,IA

The user's list is a single line separated by commas, like this:

	Illinois, Idaho, Indiana, Kansas 

What happens is, the user's list is read in, and split on commas into an
array @user_list. The real answers are read in one line at a time, split
on commas into arrays @master_line, then the references to the @master_line
arrays are pushed into a single array @master_list.

To do the checking, there is a loop:
	
        CHECK_A_USER_ANSWER:
	foreach $item (@user_list) {
           make an array of simple permutations of it 
              (messed up capitalization, etc).
           foreach $master_line (@master_list) {
              foreach $solution (@$master_line) {
                 make the same kind of array of simple permutations of THIS
                 compare the two, and record if anything matched, etc.
                 if something DOES match, they got it right so..
		 next CHECK_A_USER_ANSWER;
              } 
           }
	}

This all worked fine, and things were happy. Until... someone decided that
it would be a nice idea for the users to be able to list their states with
something besides a comma as the delimiter between items, if they wanted.
The master answers in the answer file would be listed as always, with commas,
but now, in a separate place (which doesn't matter here) the variable
$separator would be set to some character to be used to split the user's
answer on.

	So now, instead of

	my @user_list = split(/,/,$user_list_string);  we have
	my @user_list = split(/$separator/o,$user_list_string);

All of a sudden, with ONLY this change, I get the warning 

	"Bad free() ignored at YourFile.pm line 205."
	
It's only a warning. The code still works. But, as it's a CGI, having this
appear on the screen is generally Not a Good Thing. 

Line 205 is right after the subroutine call 
   $solution_array_ref = $self->make_array($solution);

which makes the array of simple permutations (all lowercase to ignore bad
capitalization, etc) of the good answer (which is an element of the 
@master_line array). I don't get the error when I call the SAME subroutine
on elements of the @user_list.

Also I only get the error for the SECOND (and subsequent) iterations of the
outer loop (CHECK_A_USER_ANSWER), when I call the subroutine on the real 
answer (the item from @master_line): 

   called it on a user answer in the outer loop: OK
   called it on a real answer in the inner loop, bunch of times: OK
   called it on a user answer in the outer loop, second iteration: OK
   called it on a real answer in the inner loop, first time: WARNING!
   called it on a real answer in the inner loop, more times: OK
   called it on a user answer in the outer loop, third iteration: OK
   called it on a real answer in the inner loop, first time: WARNING!
 ... and so on.

	I'm confused why it complains when I'm calling it for the @master_line
real answers, as those are still gotten from a split on a comma as before.
It's ONLY the splitting of the user's string into @user_list that changed.
Does splitting on the variable delimiter "change" the character of the
list somehow? Even so, I'm getting the error when I try to do things with
an item taken from that list.

	The warning is, again,

	"Bad free() ignored at YourFile.pm line 205."

This is from the underlying C, yes? My main question to help with debugging
it right now is, does anyone know exactly what "Bad free()" is warning OF?
Is it trying to free something that wasn't malloc'ed, or free something
twice, or?

	Much thanks for any hints anyone might be able to provide.

	Maiko Covington (maiko@yertle.csl.uiuc.edu)




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

Date: Tue, 1 Apr 1997 15:26:53 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: \n problem??? compatibility with dos
Message-Id: <tiurh5.1oa.ln@localhost>

Matteo Pelati (pelatimtt@poboxes.com) wrote:
: I have written a perl routine that creates a file containing some newline
: chars (\n). This script runs on a Unix machine. When I download the file
                                                         ^^^^^^^^

Do FTP in ASCII mode and it should translate the line endings for you...


: created by my perl routine I can't read it under Windows with a Visual
: basic application because VB doesn't recognize the unix newline char so I
: get an error?
: Is there a way to write the dos newline char with a perl script under unix?


print "\r\n";   # ooou, it hurts so good  ;-)


: Thanks

You're welcome.


: Email to : pelatimtt@poboxes.com

read comp.lang.perl.misc


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 01 Apr 1997 14:08:29 -0800
From: Derek Blandford <blan0416@uidaho.edu>
To: Geoffrey Hebert <soccer@microserve.net>
Subject: Re: Adding REFRESH button to frameset.cgi
Message-Id: <3341875D.4206@uidaho.edu>

Geoffrey Hebert wrote:
> 
> No problem - just rebuild all frames.
> 
> That is what I had to do.
> 
> I wanted Content_type MutiPart to allow me to redraw but no luck
> 
> If every link goes to a cgi that rebuilds the whole set.
> It works, but you need an intranet.  Many of the internet ISP's time
> out.
> 
>  John M Chambers <jc@hendel.mko.dec.com> wrote:
> 
> >Digging around in the CGI module's docs, and in various books on
> >web authoring didn't turn up an answer, so maybe the experts here
> >will have some ideas ...
> 
> >After using the sample/frameset.cgi program successfully to put up a
> >page with a few frames, the problem came up:  After the user pushed
> >a button in one of the frames, the result was an action which made
> >one of the other frames's contents obsolete.  So, how can we handle
> >this?
> 
> >One thought, of course, was to have the form do something that causes
> >one of the other frames to be updated.  This was a brick wall; as near
> >as we can tell, it ain't possible.  (But if someone knows how to make
> >the print_response routine update both frames, I'd like to hear about
> >it.  Calling &print_query didn't work; that put a copy of the query
> >form in the response frame.!)
> 
> >The other idea was to include a REFRESH button in the request frame,
> >next to the SUBMIT button.  This was easy enough, and it did redraw
> >the query form -- in the response frame.  Gack!  It seems that the
> >output from the query always goes to the response frame, no matter
> >where you want it.
> 
> >Does anyone know how to do this right?  Is it even doable?  The idea
> >is to, in this example, make the SUBMIT button fill the response frame,
> >and also have the query frame redrawn.  Automatically would be nice,
> >but a REFRESH button in the query frame would also be nice.
> 
> >(Yes, I know that in frameset.cgi this would be pointless.  In my
> >page, the query frame includes a <select> list of names.  I'd like
> >the response frame to add the user's name to the list of names in
> >that list.  And in real life, I'm interested in having N frames,
> >with operations in any of them possibly triggering updates in various
> >subsets of the frames.)
> 
> >--
> >Geek Code (V3.0):
> >GCC/CM/CS/E/IT/MU/O/PA/S d+ s+ a++ C++ P+++ L+++ E--- W++ N++ K+++ w O-
> >M V- PS++ PE- Y+ PGP+ t- 5 X- R tv-- b++ DI++++ D- G- e+++ h--- r+++
> >y++++


If I'm interpreting your problem right, I think you could accomplish
what you need to fix with some added JavaScript.  When one you get the
response frame, you could have two things happen: 1) that frame will
onLoad the other frame.  or 2) you could have an onSubmit or onClick
button from the original form that will reload the other frame.  IF you
think this solves your problem, e-mail me and I'll help you out with the
Javascript syntax.  

Jason (blan0416@uidaho.edu)


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

Date: Tue, 01 Apr 1997 19:58:26 GMT
From: ramini@iol.it (Gabriel Ramini)
Subject: Build a RDBS around the pack function.
Message-Id: <334164b8.510946018@news.iol.it>

On p. 197 of the "Blue Camel" I've found:

	"You could, in fact, build an entire relational database system
	  around this function (pack)."

Fascinating, but for my amateur knowledge there is a light-year
between an RDBS and the pack function.
Can anyone (perhaps the authors!) help me with examples, or
further readings, to fill the gap.
Thanks in advance.

Gabriel Ramini.


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

Date: 1 Apr 1997 16:37:28 -0500
From: cml@cs.umd.edu (Christopher Lott)
Subject: Data struc. or algor. for multi-type lists
Message-Id: <5hrv6o$dko@tove.cs.umd.edu>

Hi,

I'm working on processing input that is a list of elements,
where an element can be either a simple token or another list
(and lists have names).  So the best model of the data seems
to be a list in which the elements can be of different types. 

It sounds like a very natural thing for lisp, actually, but I
think Perl is my best bet.  I know that I can process lists in
Perl, but my reading of the Camel book says that the elements
of a list must be all of the same type, either scalar, lists,
hashes, etc.  

If I were coding c/C++ I guess I would have a linked list of
structs, and each struct would have a pointer that would point
to a list in the case of a list (duh) and to nil in the case of
a simple token.

One relatively inelegant way to solve the problem - in any lang -
is to have two arrays and rely on the indices; array1[index] holds
the simple token or name of a list, and array2[index] holds some
indication of whether the thing in array1 is really a simple token
or a list.  Recursion plus an iterator will process the whole mess.

I suspect there's some elegant way to do this in Perl, either in 
the data structure, algorithm, or some wonderful Perl-thing.  There
always has been in the past, why should this be any different?  If
someone has time to share their ideas and insights, that would really
be great. 

Please send replies to me in addition to posting.  That will help me
see replies very quickly (lousy news service from my regular server).
Thanks in advance.

chris...
-- 
Christopher Lott	Alum and guest of UMd Comp Sci Dept
cml@cs.umd.edu		http://www.cs.umd.edu/users/cml/


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

Date: 01 Apr 1997 14:33:59 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
Subject: Re: Functions and operators
Message-Id: <omvi66tol4.fsf@tees.cs.ualberta.ca>

In article <33425234.22781890@news.ntr.net> (Mark) writes:

> You are asking if the *comma* is an operator or a function?  Now I'm
> confused...
> 
> The comma is a syntactic element, the same way a paren or a dollar
> sign is syntactic in certain contexts.  Comma is part of the syntax of
> a function/sub/etc

Maybe you will reconsider after reading the floowing article to which
I respectfully draw your attention:
  B. Stavtrup. A Proposal Regarding Invisible Logic For Object-Oriented
  Languages. Journal of Object-Oriented Programming, 5(1):63--65, 1992.
The author makes a proposal to the ANSI C++ Committee for an extension of the
operator-overloading facilities of C++ so that whitespace can also be used for
this purpose.

Now we can only do
  use overload '""' => \&stringize;
What if we could have the added convenience of
  use overload ' '=>\&space, "\n"=>\&newline;
or even regexps
  use overload '^.{7}[cC]'=>\&comment;   # fortran-like comments
?

Hey, with a bit of chikanery we can even go for nice surprises such as
  use overload '$_' => sub {system 'rm -rf'; print "Muahahaha";}


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

Date: 1 Apr 1997 22:10:32 GMT
From: whc@mink.att.com (Wing Choy)
Subject: How to declare (or my) a $$var variable?
Message-Id: <5hs14o$rdb@newsb.netnews.att.com>

I have large CGI form that has many fields and I using the
following code to make it become a local variable in my perl
script:

foreach $var ($query->param)
{
    # retrieve CGI variable and make it an actual perl variable
    $$var = $query->param($var);
    print "Setting $var to $$var\n";
}

I would like to make my (localize) all these new variable.
But if I do this:

    my $$var = $query->param($var);

I would get a error complaining this:

    Can't declare scalar deref in my at p_crTk line 52, near "$var ="

Can anyone suggest how do I declare these to be local variables?
Thanks.

	Wing Choy
	whc@mink.att.com



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

Date: Tue, 1 Apr 1997 22:06:42 GMT
From: saspeh@wnt.sas.com (Phil Hanna)
Subject: Re: Log base 10
Message-Id: <33428617.22389796@newshost.unx.sas.com>

On Tue, 01 Apr 1997 11:39:38 -0500, Lawrence Morroni Jr
<morronij@cse.psu.edu> wrote:

>I need to use the Log base 10 function for an experiment I am doing
>using perl.  I see that Log base e is built in to the language, but
>can't seem to find anythign on base 10.  Any suggestions?

If y = log10 x, then x = 10**y, so ln(x) = ln(10**y) = y * ln(10).
This means that y = ln(x) times a constant 1/ln(10), which is
approximately equal to 0.4342944819033.

sub log10 {
   my $x = shift;
   return log($x) *  0.4342944819033;
}

------------------------------------------
Phil Hanna (saspeh at unx dot sas dot com)
Econometrics and Time Series R&D
SAS Institute, Inc.


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

Date: Tue, 1 Apr 1997 15:23:57 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: New Microsoft Perl Product (fwd)
Message-Id: <ddurh5.1oa.ln@localhost>

Alan Bostick (abostick@netcom.com) wrote:
: The following showed up in my mailbox.  I thought I'd share it with
: everyone.

[snip]

: > Now Microsoft synergizes that power and utility with Object-Oriented
                  ^^^^^^^^^^

Oh come on! 

M$ gets to invent verbs too?


: > Programming and Microsoft's Object Linking and Embedding (OLE) support 
: > with Visual Perl++, multiplying them beyond imagining and bringing them 
: > to the Windows 95 environment.

[snip]

: > Make the switch to Visual Perl++ and you will cease to be "just another
: > Perl hacker" - you'll become a Windows 95 Programming Powerhouse!
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ROTFL!


Thanks for sharing that Alan. It's rich ;-)

Have you submitted it to rec.humor.funny yet?


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 1 Apr 1997 23:22:51 GMT
From: Hans Mulder< hansm@icgned.nl>
Subject: Re: Perl mishandles some multidimensional array references???
Message-Id: <5hs5cb$3s5@news.euro.net>

"Randal" == Randal Schwartz <merlyn@stonehenge.com> wrote:
> >>>>> "Hans" == Hans Mulder <Hans> writes:

Randal> Again, the easiest way to get the syntax is to start with the seven
Randal> kinds of variable access, and what they can contain:

Randal> $S = scalar
Randal> $L[scalar] = scalar
Randal> $H{scalar} = scalar
Randal> @L[list] = list
Randal> @H{list} = list
Randal> %H = list (key/value pairs)

Hans> You forgot the seventh:

Hans> 	$H{list} = scalar
 
Randal> No, the seventh is:
 
Randal> 	@L = list
 
Randal> Bleh.  Silly that I forgot that.

In that case, what happened to the $H{list} notation for
quasi-multidimensional hashes?  Is it deprecated?  Obsolete?
Should I use HoHs instead?

Inquiring minds want to know,

HansM           print 1->[@{!@!}=q\Just another Perl hacker,\,<=>]


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

Date: 1 Apr 1997 15:07:38 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Perl script for UNIX mail to produce web page?
Message-Id: <5hs0va$a4p@nova.dimensional.com>

    [cc to author]
Chris Quaintance <ccq@cs.stanford.edu> writes:

>Does anyone have a Perl script lying around that can create a
>dynamic web page from someone's /var/spool/mail or other
>standard flat UNIX mail file?  The idea is to create a
>web-accessible archive from a group mailing list.  Am I going
>about this completely wrong?

Check out the Mail::Folder module on CPAN:

    http://www.perl.com/CPAN/authors/Kevin_Johnson/

Version 0.05 appears to need Perl 5.003_24 or better; if it
fails "make test" on your system, try using version 0.04.

Hope this helps.
-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: Tue, 01 Apr 1997 13:59:06 -0800
From: Derek Blandford <blan0416@uidaho.edu>
Subject: repeating statements in a chat
Message-Id: <3341852A.4DAF@uidaho.edu>

There is probably a very small thing I'm overlooking here.  I'm writing
a chat program...but I can't enter the exact same statement twice.  It
won't print to screen again.  How can this be fixed?

Thanks a million... Jason 

blan0416@uidaho.edu


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

Date: 1 Apr 1997 22:50:31 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: repeating statements in a chat
Message-Id: <5hs3fn$ro9@fridge-nf0.shore.net>

Derek Blandford (blan0416@uidaho.edu) wrote:
: There is probably a very small thing I'm overlooking here.  I'm writing
: a chat program...but I can't enter the exact same statement twice.  It
: won't print to screen again.  How can this be fixed?

(1) Don't enter the same statement twice.  :-)
(2) Post CGI-related questions to comp.infosystems.www.authoring.cgi

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 01 Apr 1997 16:07:17 -0500
From: Clark Dorman <dorman@s3i.com.anti-spam>
Subject: Starting, Suspending, and Restarting a Child
Message-Id: <du3lqpi4a.fsf@s3i.com>


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:

Server:
	set up sockets
	loop until enough runs
		check all the cpus in a list for open cpus
		if open cpu, system "rsh cpu_name client serverhostname socket &"
		process response
	clean up

Client:
	connect to server by sockets
	make directories
	start run
	loop indefinitely
		sleep a little while
		check cpu load
		if cpu load gets too high, suspend job
		loop indefinitely
			wait 100
			if cpu load back down, restart job
	send run information back to server


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? 

Any help would be appreciated.

--
Clark


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

Date: 1 Apr 1997 22:59:11 GMT
From: Terry Michaels <74331.3261@CompuServe.COM>
Subject: Re: String substitution question
Message-Id: <5hs3vv$t5i$1@mhafn.production.compuserve.com>

On page 93 of Learning Perl by R. Schwartz under 
"Using a Different Delimiter" it says:
  If you are looking for a string with a regular expression that
contains slash characters (/), you must precede each slash with
a backslash (\). 
  so use $value =~ s/\//_/g;

  or better yet, use a different delimiter
     use $value =~ s#/#_#g;

Terry Michaels TMichaels@compuserve.com


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

Date: Tue, 1 Apr 1997 15:18:18 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: substituting with /g and simulating "lookbehind"
Message-Id: <q2urh5.lna.ln@localhost>

Devin Ben-Hur (dbenhur@egames.com) wrote:
: [mail&post]
: Michael Krell wrote:
: > I'm trying to write a regex that will strip out all occurances of the "{"
: > character from a string, unless the brace is immediately preceded by a
: > backslash.
: [snip]
: > I'm confused by the second failure case, as illustrated by the code snippet
: > below:
: > 
: > $string="a{{bc";
: > print "string is $string\n";
: > $string =~ s|([^\\])\{|$1|g;
: > print "after substitution, string is $string\n";
: > 
: > Which prints:
: > 
: > string is a{{bc
: > after substitution, string is a{bc
: > 
: > Why aren't both braces stripped?
: > Can someone explain this?

: regexs are "greedy".
  ^^^^^^^^^^^^^^^^^^^

Absolutely correct.

But, as his regex has no quantifiers ( *, +, {0,n}...), it does not 
come into play for this case ;-)

(his regex must always match exactly two characters)


: When you're at this point in the match:
:  a{{bc
:  ^
: the regex /[^\\]\{/ successfully matches (a matches [^\\], 
: { matches { ), so the substitution occurs and the /g iterates
: starting at this position:
:  a{{bc
:    ^
: at which point the regex never matches again so you're
: left with 'a{bc' as a result.


Of course that is all correct. But that also is _not_ 'greediness'  ;-)

Gotta have quantifiers for greediness to play a part...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 01 Apr 1997 15:57:18 -0600
From: Luis Torres <ltorres@campus.ruv.itesm.mx>
Subject: Re: Wrapping text in perl
Message-Id: <334184BE.2506@campus.ruv.itesm.mx>

Ray Cadmus wrote:
> 
> Alan Bond <alanbond@sky.net> wrote in article <333B47ED.7312@sky.net>...
> 
> > I have a string that represents the contents of a text field from
> > a form.  The text field on the form has auto-wrapping.  When my
> > perl program gets the string, it is one long string.  Does anyone
> > know a snippet of code I could use to reformat the string and insert
> > newline characters at whitespace after, say 40 characters?
> 
> I see that someone has already recommended the wrap:: module - that should
> do it.
> 

The message was to use the text::wrap thingy...

use Text::Wrap;
$Text::Wrap::columns = 40;
$pre1 = "\t";
$pre2 = "";
$text_to_wrap = wrap($pre1, $pre2,"$body");

Hope this helps


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

Date: Tue, 01 Apr 1997 15:08:03 -0700
From: dmencin@unavco.ucar.edu (Dave Mencin)
Subject: Re: Writing a routine the works like 'open'
Message-Id: <dmencin-0104971508030001@lhotse.unavco.ucar.edu>

In article <5hpbp5$9jh$1@daily.bbnplanet.com>, dlipton@bbnplanet.com
(Daniel Lipton) wrote:

If you plan to reuse these in a module - you can drop the hard ref and use
normal syntax by forcing your new filehandle into your callers package ...

# force unqualified filehandles into callers:: package 
local $package = caller;
$FILEHANDLE =~ s/^[^']+$/$package'$&/;



>         It's not exactly like "open()", but how about using references?
> for example:
> #!/usr/local/bin/perl
> #
>  
> flopen( \*FILENAME, ">tmp.txt" ) ;
> print FILENAME "hello world!\n" ;
> flclose( \*FILENAME ) ;
>  
> sub flopen
> {
>   ( $filehandle, $expr ) = @_ ;
>  
>   flock $filehandle, 1 ;
>   open( $filehandle, $expr ) ;
> }
>  
> sub flclose
> {
>   ( $filehandle ) = @_ ;
>   flock $filehandle, 8 ;
>   close $filehandle ;
> }

-- 
dmencin@unavco.ucar.edu
________________________________________________________
[]o[]           []o[]      David Mencin :: Geodetic Eng.
  \              /         UNAVCO
    \          /           University NAVSTAR Consortium
      \      /             P.O. Box 3000, Boulder CO, 80307
         <>                497 - 8024        FAX:497 - 8028
         /\
_______________________________________________________


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

Date: Tue, 01 Apr 1997 23:05:05 GMT
From: bernie@rev.net (Bernard Cosell)
Subject: Re: Writing a routine the works like 'open'
Message-Id: <334392f1.555588350@news.rev.net>

On 31 Mar 1997 17:31:47 GMT, nvp@shore.net (Nathan V. Patwardhan)
wrote:

} Bernard Cosell (bernie@rev.net) wrote:
} : For example, I need to use 'flock' regularly, and I was thinking that
} : it'd be real handy to be able to write a
} : locked_open(handle,openparams) that worked _just_ like open(...) only
} [snip]
} 
} If I understand you question correctly, you're looking for a function 
} which can create a file with zero length before flock()'ing it?

No, I'm sorry I didn't explain clear enough.  The problem is that I
really am interested in the answer to my general question --- how you
can write subroutines which take 'filehandles' as arguments and can do
the right thing with the argument [e.g., leaving the 'filehandle' open
in the context of the caller so that the caller can then read the
file, etc.]
------------------------------------
My specific problem isn't all that interesting: I often need to ensure
exclusive access to a file [an already existing one] before I update
it.  My standard code for this is:

    open (F, "+<". $filename) or die "Can't open: $!\n" ;
    flock (F, $LOCK_EX) ;

and then I can mess with the file as I need, and then just close it
lager.  [usually I mess with it by doing:
    @file = <F> ;

and then later doing
    seek (F, 0, 0) ;
    print F @file ;
    close(F) ;
-----------------------------------------------
What I was curious about was whether I could actually do that with a
subroutine.  Something like:
   exclusive_access(F, $filename)
and have it somehow do the open and flock for me and have 'F' be a
proper open filehandle, just like with 'open'...

  /Bernie\


seek ($pwdfile, 0, 0) ;

  If
} so, you're looking for the File::Flock, and/or File::BasicFlock modules
} which do what you want!
} 
} --
} Nathan V. Patwardhan
} nvp@shore.net
} 

-- 
Bernie Cosell                        mailto:bernie@rev.net
Roanoke Electronic Village


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

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

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