[19500] in Perl-Users-Digest
Perl-Users Digest, Issue: 1694 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 5 08:45:32 2001
Date: Wed, 5 Sep 2001 03:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <999684314-v10-i1694@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 5 Sep 2001 Volume: 10 Number: 1694
Today's topics:
Re: ActivePerl says Out of Memory, but I'm not out of m <bwalton@rochester.rr.com>
Re: ActivePerl says Out of Memory, but I'm not out of m (Jonadab the Unsightly One)
Re: can this be done with regex? (stupid question proba <uri@sysarch.com>
Getting pack results interpreted as unicode. <goldbb2@earthlink.net>
Re: Getting pack results interpreted as unicode. (Rafael Garcia-Suarez)
Godzilla DOS Internal Script Timer <godzilla@stomp.stomp.tokyo>
Re: Godzilla DOS Internal Script Timer <wyzelli@yahoo.com>
Re: Godzilla DOS Internal Script Timer <godzilla@stomp.stomp.tokyo>
Re: Godzilla DOS Internal Script Timer <godzilla@stomp.stomp.tokyo>
Re: Godzilla DOS Internal Script Timer <Thomas@Baetzler.de>
Help ! Porting from unix to windows, unicode problem (Bernard Polarski)
HELP! Syntax error on a simple if then command <gvandyke@voyager.net>
Re: HELP! Syntax error on a simple if then command (Chris Fedde)
Re: HELP! Syntax error on a simple if then command <andrew.savige@ir.com>
Re: HELP! Syntax error on a simple if then command <Jon.Ericson@jpl.nasa.gov>
Re: How can I find the PID's of my children? (Ilja Tabachniks)
Re: How can I find the PID's of my children? <krahnj@acm.org>
how to check if a .tar.gz is complete? <cosmos@hepcat.org>
Re: how to check if a .tar.gz is complete? (Ilja Tabachniks)
Re: how to check if a .tar.gz is complete? <bart.lateur@skynet.be>
Re: how to get named constants in Perl (David Combs)
Re: how to get named constants in Perl <godzilla@stomp.stomp.tokyo>
Re: How to I background a process and not wait for it. <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 05 Sep 2001 02:29:09 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: ActivePerl says Out of Memory, but I'm not out of memory? Is this a limitation in the Perl build I have?
Message-Id: <3B958DDA.7A70D441@rochester.rr.com>
Jonadab the Unsightly One wrote:
>
> #!perl
> $_="
> Bob Walton wrote:
> > Please whittle your script down to the smallest number of
> > lines that will execute verbatim if copy/pasted and will
> > also illustrate the problem you have having, and repost.
>
> Okay, I've got it under 100 lines, and if I try to make it any
> shorter it'll be obfuscated; already it's lacking comments...
>
<script deleted>
...
> # --jonadab
I tried your script (after adding the two periods around line 24 that
somehow got deleted in the translation) and got an Out of memory!
error after about 6.5 seconds. My machine: 1 GHz Athlon, 512 Mb
memory, Windoze 98SE, AS Perl 5.6.1 build 628. Also RH Linux 7.1
(didn't try it there yet). No ideas off the top, maybe later.
--
Bob Walton
------------------------------
Date: Wed, 05 Sep 2001 03:52:48 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: ActivePerl says Out of Memory, but I'm not out of memory? Is this a limitation in the Perl build I have?
Message-Id: <3b958f9b.13502554@news.bright.net>
mgjv@tradingpost.com.au (Martien Verbruggen) wrote:
> It looks like you're working with a potentially very long
> string there. When The string is, say, 30 MB,
It's not anywhere *near* that long. The longest version
of the string before the "Out of memory!" bailout was
under 150K. That's a long string, but it's not long
enough that contiguous memory is going to be an issue.
The larger issue is that there are thousands of copies
of everything -- the string, %stack, and some smaller
stuff (e.g., $card). (The total length of the seven
strings stored in %stack should never exceed 104
characters or so, but you've got the hash overhead...)
However, logging the contents of $moves to disk as the
script goes along is proving to be a potent diagnostic
tool; I already found and squashed one bug as a result
of doings so, and I haven't even gone over it very
carefully yet... originally I just wanted to know
how *big* $moves was getting, but its contents are
actually more helpful.
> Maybe you should reconsider your algorithm, or start using my, instead
> of local() more. Or maybe try to solve this iteratively, instead of
> recursively.
What I may end up doing is limiting the recursion to a
certain number of levels, then write progress out to
disk, bail, and resume where it left off on next run.
With a shell script that just calls it repeatedly
until it finds the solution file to be present. But
I'll look through those logged files first and see
if I can find any more lurking bugs...
- jonadab
------------------------------
Date: Wed, 05 Sep 2001 04:25:23 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: can this be done with regex? (stupid question probably)
Message-Id: <x7wv3efem7.fsf@home.sysarch.com>
>>>>> "TM" == Tina Mueller <tinamue@zedat.fu-berlin.de> writes:
TM> did you read perldoc perlop | perlfunc?
TM> substr($_,-1,1) =~ tr/{ABCDEFGH]/0123456789/;
good use of lvalue substr. but what about tr ranges?
substr($_,-1,1) =~ tr/{A-H]/0-9/;
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 05 Sep 2001 02:55:18 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Getting pack results interpreted as unicode.
Message-Id: <3B95CC56.E6CAC4F0@earthlink.net>
Both strings created with v<digits> and pack U, <digits> print out the
same, but they clearly aren't the same internally:
$ perl -e 'print v2147483647'
ý¿¿¿¿¿
$ perl -e 'print pack U, 2147483647'
ý¿¿¿¿¿
perl -e 'print "ok" if v2147483647 eq pack U, 2147483647'
ok
$ perl -e 'printf "%vd", v2147483647'
2147483647
$ perl -e 'printf "%vd", pack U, 2147483647'
253.191.191.191.191.191
What does printf see that I don't?
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: 5 Sep 2001 07:19:34 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Getting pack results interpreted as unicode.
Message-Id: <slrn9pbkge.nnt.rgarciasuarez@rafael.kazibao.net>
Benjamin Goldberg wrote in comp.lang.perl.misc:
} Both strings created with v<digits> and pack U, <digits> print out the
} same, but they clearly aren't the same internally:
[ ... ]
} $ perl -e 'printf "%vd", pack U, 2147483647'
} 253.191.191.191.191.191
What perl version are you using ? I can't reproduce this.
} What does printf see that I don't?
Have you tried Devel::Peek ?
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Wed, 05 Sep 2001 00:49:05 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Godzilla DOS Internal Script Timer
Message-Id: <3B95D8F1.CE84720F@stomp.stomp.tokyo>
Interpolate benchmark results my big fat butt!
Recently, the CLPM Troll proclaimed he could
interpolate benchmark results to reflect the
actual single run time of any given code. GAK!
For benchmark, you can only extrapolate a single
run time instance of code, at significant risk.
Any of you Sissified Geeks actually take the time
to research and read about interpolate versus
extrapolate? I didn't think so.
Here is a method of timing segments of code within
a Perl script. This method eliminates startup and
execution time for perl core, entirely. Using this
method also minimizes Windows background noise.
* wonders if I should mention the fifty-five factor *
Nah... this is beyond Perl 5 Cargo Cultists.
My rather ingenious method is pretty darn accurate
and can be used to compare any number of Perl code
segments, anywhere in a Perl script.
This targets Win9.x and Win.me only.
My basis for this method is a simple DOS command
I doubt any of you ever use:
echo.|time
Try this at a DOS prompt. This will return the
time and kill the prompt for new date entry,
although the text is displayed. A format will
appear like this, immediately followed by a DOS
prompt. Check your return. My code is based on
this _exact_ DOS returned format:
Current time is 11:30:57.65p
Enter new time:
Is this another amazing bit of genius on my part?
Darn tootin! You Perl 5 Cargo Cultists can't hold
a candle to me! However, sometimes my boyfriend
drips hot candle wax on me... hmm...
Here is my rather simple but ingenious code:
#!perl
$start = `echo.|time`;
## Insert your code to test here.
$stop = `echo.|time`;
&Calculate_Time;
sub Calculate_Time
{
$start = substr ($start, 22, 5);
$stop = substr ($stop, 22, 5);
($second1, $millisecond1) = split (/\./, $start);
($second2, $millisecond2) = split (/\./, $stop);
if ($second2 > $second1)
{
$thousands = $second2 - $second1 * 1000;
$millisecond1 = $thousands - $millisecond1;
$runtime = $millisecond1 + $millisecond2;
}
else
{ $runtime = $millisecond2 - $millisecond1; }
print "Godzilla Runtime: $runtime milliseconds.\n\n";
}
exit;
You will note I do not include code to compensate for
minute rollover. Chances are relatively low you will
catch a minute rollover, but not entirely impossible.
Just run your code again, if so, or add coding to my
method to account for minute rollover circumstances
if this possibility wigs you to sexual impotence.
You may run this code from a DOS prompt or as a cgi
with addition of a content type.
Below my signature is a test script you may run to
observe how this works. Syntax is, to compensate
for CGI.poopmaker which cannot recognize a query
string inside a script, which is real stupid, syntax
needs to compensate for Perl 5 Cargo Cult cgi.poopmaker,
at your DOS prompt:
C:\PERL> perl test.pl north=north&south=south&east=east&west=west
Otherwords, You need to add a query string so cgi.poopmaker will
work right, which it rarely does, even the latest version which
does recognize an internal query string, or so claimed.
A reminder here for you knowing none of you pay attention, my
method does not include compensation for minute rollover and,
there will inherently be some random Windows background noise.
Multiple runs and averaging will yield even higher accuracy.
My tests indicate an accuracy of plus or minus one millisecond
for any given single run.
Incidently, the CLPM Troll says his highly accurate interpolation
of benchmark results I posted, clearly and factually indicates
cgi.poopmaker will take one point twenty-second milliseconds
longer to run using comparative codes precisely as shown in
my test script beneath my internationally famous signature.
* laughs *
So far, I have solved how to set parent DOS environmental variables
using Perl, which has been said for decades to be impossible. I have
created a method to time scripts for just a handful of runs where
benchmark cannot and, now have developed a method using Perl to
internally time code snippets with darn good accuracy. All of these
accomplishments are done so with no Perl 5 Cargo Cult modules.
Amazing, ain't I?
What have you Perl 5 Cargo Cultists accomplished lately which is amazing?
Godzilla! Queen Of Perl Heretics.
--
Don't forget to add a prompt query string for cgi.poopmaker.
Incidently, do you think "use CGI" skews all results?
#!perl
$start = `echo.|time`;
$ENV{QUERY_STRING} = "north=north&south=south&east=east&west=west";
$buffer = $ENV{QUERY_STRING};
@checks = split(/&/, $buffer);
foreach $check (@checks)
{
($name, $value) = split(/=/, $check);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
$north = "$FORM{north}";
$south = "$FORM{south}";
$east = "$FORM{east}";
$west = "$FORM{west}";
$stop = `echo.|time`;
&Calculate_Time;
$start = `echo.|time`;
use CGI;
my $query = new CGI;
$north = $query->param(north);
$south = $query->param(east);
$east = $query->param(south);
$west = $query->param(west);
$stop = `echo.|time`;
&Calculate_Time;
sub Calculate_Time
{
$start = substr ($start, 22, 5);
$stop = substr ($stop, 22, 5);
($second1, $millisecond1) = split (/\./, $start);
($second2, $millisecond2) = split (/\./, $stop);
if ($second2 > $second1)
{
$thousands = $second2 - $second1 * 1000;
$millisecond1 = $thousands - $millisecond1;
$runtime = $millisecond1 + $millisecond2;
}
else
{ $runtime = $millisecond2 - $millisecond1; }
print "Godzilla Runtime: $runtime milliseconds.\n\n";
}
exit;
------------------------------
Date: Wed, 5 Sep 2001 17:43:27 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Godzilla DOS Internal Script Timer
Message-Id: <W2ll7.1$cL5.290@wa.nnrp.telstra.net>
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3B95D8F1.CE84720F@stomp.stomp.tokyo...
>
> Interpolate benchmark results my big fat butt!
>
> Recently, the CLPM Troll proclaimed he could
> interpolate benchmark results to reflect the
> actual single run time of any given code. GAK!
>
> For benchmark, you can only extrapolate a single
> run time instance of code, at significant risk.
>
> Any of you Sissified Geeks actually take the time
> to research and read about interpolate versus
> extrapolate? I didn't think so.
EXTRAPOLATE:
a : to infer values of a variable in an unobserved interval from values
within an already observed interval
b : to project, extend, or expand known data or experience into an area not
known or experienced so as to arrive at a usually conjectural knowledge of
the unknown area
INTERPOLATE:
to estimate values of a function between two known values
Therefore to estimate the runtime of a single instance of a program
(function) from observed results of 100,000 runtimes is interpolation.
Also note the use of the word INFER which you also seem to have a problem
with, instead of IMPLY.
No doubt this will be referred to as 'mule manure' but then obviously
dictionary compilers know nothing compared to our learned 'Professor of
English'.
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_!=1)? 's':'';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Wed, 05 Sep 2001 01:17:56 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Godzilla DOS Internal Script Timer
Message-Id: <3B95DFB4.38A368A6@stomp.stomp.tokyo>
Godzilla! wrote:
> cgi.poopmaker will take one point twenty-second milliseconds
My mind's eye blinked.
"...one point twenty-seven milliseconds...."
An excellent method to catch spelling errors
within text, this is, if you want to be a better
speller, is to read text backwards while watching
for errors in spelling.
No con. Train yourself to read text backwards.
This really works and, is a method I teach my
students to use to improve spelling skills.
.Pencils Line Red Of Queen Godzilla!
------------------------------
Date: Wed, 05 Sep 2001 01:34:53 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Godzilla DOS Internal Script Timer
Message-Id: <3B95E3AD.A4514A37@stomp.stomp.tokyo>
Wyzelli aka The CLPM Troll wrote:
> Godzilla!
> > Interpolate benchmark results my big fat butt!
> > Recently, the CLPM Troll proclaimed he could
> > interpolate benchmark results to reflect the
> > actual single run time of any given code. GAK!
> > For benchmark, you can only extrapolate a single
> > run time instance of code, at significant risk.
> > Any of you Sissified Geeks actually take the time
> > to research and read about interpolate versus
> > extrapolate? I didn't think so.
> EXTRAPOLATE:
> a : to infer values of a variable in an unobserved interval from values
> within an already observed interval
> b : to project, extend, or expand known data or experience into an area not
> known or experienced so as to arrive at a usually conjectural knowledge of
> the unknown area
"...conjectural knowledge of the unknown area"
> INTERPOLATE:
> to estimate values of a function between two known values
"...between two known values."
"...BETWEEN TWO KNOWN VALUES."
> Therefore to estimate the runtime of a single instance of a program
> (function) from observed results of 100,000 runtimes is interpolation.
> Also note the use of the word INFER which you also seem to have a problem
> with, instead of IMPLY.
> No doubt this will be referred to as 'mule manure' but then obviously
> dictionary compilers know nothing compared to our learned 'Professor of
> English'.
Your is not Mule Manure. Normally I would state yours is
poor reading comprehension.
However, this time, I elect to state,
"Yours is flat-out stupidity."
Godzilla! Queen Of Maleegostompia.
--
mph: miles per hour
seconds: elapse time from dead stop to given mph
interpolate seconds for mph equals 45
My Mako Shark Corvette displays this performance:
zero to thirty mph in three seconds.
zero to sixty mph in five seconds.
zero to one-hundred mph in eleven seconds.
zero to one-hundred-twenty mph in thirteen seconds.
extrapolate seconds for mph equals 200 mph, maximum speed.
You cannot interpolate results outside given known boundries
for non-linear relationships; benchmark is non-linear.
------------------------------
Date: Wed, 05 Sep 2001 12:02:30 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Godzilla DOS Internal Script Timer
Message-Id: <2jtbpts9d595r7a7v6ltrf7rd9g0s1jqvh@4ax.com>
On Wed, 05 Sep 2001, "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
[snip]
>My rather ingenious method is pretty darn accurate
>and can be used to compare any number of Perl code
>segments, anywhere in a Perl script.
Anywhere where you may use backticks and obviously only where you have
access to a time command. And also obviously only up to the precision
of said command's internal clock.
>echo.|time
Any particular reason why you don't use "time <nul"?
>Is this another amazing bit of genius on my part?
Very impressive.
If you're timing code town to milliseconds, you should at least factor
in the time needed to fire up your second time command.
HTH,
--
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.
------------------------------
Date: 5 Sep 2001 01:04:57 -0700
From: bpolarsk@yahoo.com (Bernard Polarski)
Subject: Help ! Porting from unix to windows, unicode problem
Message-Id: <80eb5d07.0109050004.47c63cd6@posting.google.com>
I try to run a script that run perfectly on Solaris to windows 2000.
After port to win2K, I always receive this message :
"Can't find unicode character property definition via main->e or e.pl
at unicode/Is/ls e.pl line 0"
I made extensive research on the net with part of this message and
found no real help. I remove the first line ("#!/usr/bin/perl") but
nothing changes.
------------------------------
Date: Tue, 4 Sep 2001 22:25:11 -0500
From: "George Vandyke" <gvandyke@voyager.net>
Subject: HELP! Syntax error on a simple if then command
Message-Id: <3b959c66$0$42873$272ea4a1@news.execpc.com>
Help I am getting syntax errors on the below if-then and I have been
knocking my brains out for a couple of hours trying to figure out
why this seeming simple thing does not work.
Any help would be greatly appreciated. BTW, I am using Active Perl
5.6 on a Windows 2000 machine.
Thanks,
George
gvandyke@voyagerREMOVE.net
# Loop through all reference points checking duplicates.
# Assign the index of a
#
$i = -1;
while (++$i <= $array_index) {
$j = $i+1;
while ($j <= $array_index ) {
If ( $x_loc[$i] == $x_loc[$j] && $y_loc[$i] == $y_loc[$j]
&& $z_loc[$i] == $z_loc[$j] && $i != $j ) { # line 83
$k++; # a duplicate was found
$dup_index[$k] = $j;
}
print ("i = $i, j = $j, k = $k, array_index = $array_index\n");
$debug = <STDIN>;
$j++;
}
} # line 91
The errors are:
syntax error at read_xyz.pl line 83, near ") {"
syntax error at read_xyz.pl line 91, near "}"
Execution of read_xyz.pl aborted due to compilation errors.
--
George Vandyke
gvandyke@voyager.net
------------------------------
Date: Wed, 05 Sep 2001 03:40:21 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: HELP! Syntax error on a simple if then command
Message-Id: <F8hl7.127$Owe.191928320@news.frii.net>
In article <3b959c66$0$42873$272ea4a1@news.execpc.com>,
George Vandyke <gvandyke@voyager.net> wrote:
> while ($j <= $array_index ) {
> If ( $x_loc[$i] == $x_loc[$j] && $y_loc[$i] == $y_loc[$j]
> && $z_loc[$i] == $z_loc[$j] && $i != $j ) { # line 83
> $k++; # a duplicate was found
> $dup_index[$k] = $j;
> }
Perl is case sensitive. Check that If!
Good Luck
--
This space intentionally left blank
------------------------------
Date: Wed, 5 Sep 2001 13:40:42 +1000
From: "Knob" <andrew.savige@ir.com>
Subject: Re: HELP! Syntax error on a simple if then command
Message-Id: <_8hl7.5$y73.6834@news0.optus.net.au>
"George Vandyke" <gvandyke@voyager.net> wrote in message
news:3b959c66$0$42873$272ea4a1@news.execpc.com...
> Help I am getting syntax errors on the below if-then and I have been
> knocking my brains out for a couple of hours trying to figure out
> why this seeming simple thing does not work.
>
> Any help would be greatly appreciated. BTW, I am using Active Perl
> 5.6 on a Windows 2000 machine.
>
> Thanks,
> George
> gvandyke@voyagerREMOVE.net
>
> # Loop through all reference points checking duplicates.
> # Assign the index of a
> #
> $i = -1;
> while (++$i <= $array_index) {
> $j = $i+1;
> while ($j <= $array_index ) {
> If ( $x_loc[$i] == $x_loc[$j] && $y_loc[$i] == $y_loc[$j]
> && $z_loc[$i] == $z_loc[$j] && $i != $j ) { # line 83
> $k++; # a duplicate was found
> $dup_index[$k] = $j;
> }
> print ("i = $i, j = $j, k = $k, array_index = $array_index\n");
> $debug = <STDIN>;
> $j++;
> }
> } # line 91
>
>
> The errors are:
> syntax error at read_xyz.pl line 83, near ") {"
> syntax error at read_xyz.pl line 91, near "}"
> Execution of read_xyz.pl aborted due to compilation errors.
>
> --
> George Vandyke
> gvandyke@voyager.net
>
Your 'if' statement has a capital 'i' (If).
------------------------------
Date: 04 Sep 2001 20:27:46 +0000
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: HELP! Syntax error on a simple if then command
Message-Id: <863d62pupp.fsf@jon_ericson.jpl.nasa.gov>
"George Vandyke" <gvandyke@voyager.net> writes:
> # Loop through all reference points checking duplicates.
> # Assign the index of a
> #
> $i = -1;
^
You're not using strict (perldoc strict for more information). I'd
really recommend getting in the habit of using it. One consequence is
that you will want to add `my' here.
> while (++$i <= $array_index) {
A lot of times in perl you can avoid using indexes such as $i to
access the elements of an array with something like:
for my $loc (@x_loc){
But in this case it looks like you may need the index. The C-style
for loop is often used in this case:
for (my $i=0; $i < $array_index; $i++){
(I think I avoided off-by-one errors in the translation.) One nice
thing about this style (as opposed to yours) is that the loop code is
compact and recognizable (at least to former C programmers). Another
is that $i is properly scoped.
> $j = $i+1;
> while ($j <= $array_index ) {
Once again I prefer the C-style. I also wonder if `map' might not be
more clear (though I haven't actually tried it).
> If ( $x_loc[$i] == $x_loc[$j] && $y_loc[$i] == $y_loc[$j]
^
Here's a typo. Perl is case sensitive.
> && $z_loc[$i] == $z_loc[$j] && $i != $j ) { # line 83
I don't see how $i and $j could ever be the same.
> $k++; # a duplicate was found
> $dup_index[$k] = $j;
$k seems entirely vestigial. Consider:
push @dup_index, $j;
> }
> print ("i = $i, j = $j, k = $k, array_index = $array_index\n");
> $debug = <STDIN>;
> $j++;
For consistency's sake this should be up in the while statement.
> }
> } # line 91
This provokes a syntax error because it's an unmatched curly.
You might want to look into a syntax-highlighting editor (I use
emacs).
Jon
------------------------------
Date: 5 Sep 2001 00:57:49 -0700
From: billy@arnis-bsl.com (Ilja Tabachniks)
Subject: Re: How can I find the PID's of my children?
Message-Id: <5d4a715a.0109042357.28dcccb5@posting.google.com>
stanb@panix.com (Stan Brown) wrote in message news:<9n39c8$imf$1@panix2.panix.com>...
...skipped...
> Thanks for the example code, but I would prefer not to have to clutter
> global variable space with yet another array, because of callbacks etc. I
> already have _way_ more global data than I normally like.
> So I was hoping for a function that would allow a perl script to look at
> the process table, and determine from there what tasks it is the parrent
> of.
AFAIK, there is no portable way to get all the children pids
of the current process.
But you could try to run the external ps(1) command and parse it's output:
#!/usr/bin/perl -w
use strict;
my @children = ();
open PS, "ps -e -o ppid,pid 2>/dev/null |" or die "cannot fork: $!\n";
<PS>; # skip the header
while (<PS>)
{
my ($ppid, $pid) = split;
push @children, $pid if $ppid == $$;
}
close PS or die "bas news from ps: $! $?\n";
# at this point @children should contain a list of childrens' pids
Please note that the code above will include the pid of 'ps'
into @children - feel free to avoid it if required.
Hope this helps,
Ilja.
------------------------------
Date: Wed, 05 Sep 2001 09:50:18 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How can I find the PID's of my children?
Message-Id: <3B95F5D0.47AF2099@acm.org>
Ilja Tabachniks wrote:
>
> stanb@panix.com (Stan Brown) wrote in message news:<9n39c8$imf$1@panix2.panix.com>...
>
> ...skipped...
>
> > Thanks for the example code, but I would prefer not to have to clutter
> > global variable space with yet another array, because of callbacks etc. I
> > already have _way_ more global data than I normally like.
> > So I was hoping for a function that would allow a perl script to look at
> > the process table, and determine from there what tasks it is the parrent
> > of.
>
> AFAIK, there is no portable way to get all the children pids
> of the current process.
>
> But you could try to run the external ps(1) command and parse it's output:
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my @children = ();
>
> open PS, "ps -e -o ppid,pid 2>/dev/null |" or die "cannot fork: $!\n";
>
> <PS>; # skip the header
> while (<PS>)
> {
> my ($ppid, $pid) = split;
> push @children, $pid if $ppid == $$;
> }
>
> close PS or die "bas news from ps: $! $?\n";
my $command = 'ps -eo ppid,pid,command';
my @children = grep {
chomp( my @x = split " ", $_, 3 );
$x[0] == $$ and $x[2] ne $command and $_ = $x[1]
} `$command`;
> # at this point @children should contain a list of childrens' pids
>
> Please note that the code above will include the pid of 'ps'
> into @children - feel free to avoid it if required.
John
--
use Perl;
program
fulfillment
------------------------------
Date: 5 Sep 2001 01:08:36 GMT
From: The Linux AntiChrist <cosmos@hepcat.org>
Subject: how to check if a .tar.gz is complete?
Message-Id: <9n3tuk$g1i$1@bob.news.rcn.net>
im looking at the Archive::Tar module to do something like this
check whether any given file.tar.gz is complete, aka not truncated or corrupted. we get alot
of files uploaded for processing and rather than just attempting to process the file i would
like to check whether it can be untarred completely.
are there any example code modules out there that does this? the docs for the Archive::Tar module
are not very complete.
thanks
------------------------------
Date: 4 Sep 2001 23:46:53 -0700
From: billy@arnis-bsl.com (Ilja Tabachniks)
Subject: Re: how to check if a .tar.gz is complete?
Message-Id: <5d4a715a.0109042246.403ef5e4@posting.google.com>
The Linux AntiChrist <cosmos@hepcat.org> wrote in message news:<9n3tuk$g1i$1@bob.news.rcn.net>...
>
> im looking at the Archive::Tar module to do something like this
> check whether any given file.tar.gz is complete, aka not truncated or
> corrupted. we get alot of files uploaded for processing and rather
> than just attempting to process the file i would like to check whether
> it can be untarred completely.
> are there any example code modules out there that does this? the docs
> for the Archive::Tar module are not very complete.
>
I'm almost sure you can accomplish your task with Archive::Tar
and Compress::Zlib ... but I cannot remember right now :-(
However, another way is to use an external tar command
(may be system-dependent):
my $some_file = 'some_file.tar.gz';
system("tar tzf $some_file >/dev/null 2>&1");
print $? ?
"file $some_file looks corrupted (or tar failed to start)\n" :
"file $some_file looks ok\n"
Or instead of a system() call you could use backticks/pipes
to capture tar's output.
Hope this helps,
Ilja.
------------------------------
Date: Wed, 05 Sep 2001 07:59:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: how to check if a .tar.gz is complete?
Message-Id: <85mbpt0g1dc9kvcpc4qnv83srtab8s2s1l@4ax.com>
The Linux AntiChrist wrote:
>im looking at the Archive::Tar module to do something like this
>
>check whether any given file.tar.gz is complete, aka not truncated or corrupted. we get alot
>of files uploaded for processing and rather than just attempting to process the file i would
>like to check whether it can be untarred completely.
>
>are there any example code modules out there that does this? the docs for the Archive::Tar module
>are not very complete.
Note that .tar.gz is in fact a .tar file that got gzipped. For a file
corruption test, all you need to do is check if gunzip, or rather,
Compress::Zlib, can handle it. You can check out how Archive::Tar does
it (yes, by looking at the source...) or use one of zlib's gz*
functions. See <http://www.gzip.org/zlib/manual.html> for zlib's
reference manual.
--
Bart.
------------------------------
Date: 5 Sep 2001 06:00:12 GMT
From: dkcombs@panix.com (David Combs)
Subject: Re: how to get named constants in Perl
Message-Id: <9n4f1c$776$2@news.panix.com>
In article <v1vmotsrabehf37li644um7h1jfhl4m4vf@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> wrote:
>...
>Hmmm... I don't like the inconvenience, without "use strict", of having
>misspelled constants suddenly popping up as bareword strings.
>
>Oh, so I should always use strict, anyway? There's a reason why it's not
>on by default. It's inconvenient for smallish scripts. It may result in
>what can be called "declaratitis", where setting up the script takes
>more space than the actual code.
From my (careless) experience, I can misspell a name
EASIER in a SMALL script than in a big one.
Like when I was a kid, spending lots of time out in
west Texas -- shooting (with 22 long-rifle bullets)
jack rabbits (not cute like cotton-tails, not clean either,
diseased, PLUS 30 of them were said to eat as much as
a cow) -- I could pretty usually hit the ones way off,
but let there be one ten feet out the car window,
or even closer, I'd always miss.
For me, strict gets used for *all* scripts.
(Anything that lets the *computer* find my stupid
misspellings for me is ok by me -- vastly better
than for my eyes having to do it!)
David
------------------------------
Date: Wed, 05 Sep 2001 00:55:20 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: how to get named constants in Perl
Message-Id: <3B95DA68.D20CFF35@stomp.stomp.tokyo>
David Combs wrote:
> Bart Lateur wrote:
(snipped)
> (Anything that lets the *computer* find my stupid
> misspellings for me is ok by me -- vastly better
> than for my eyes having to do it!)
If you do not discipline your mind, if you do not
train your mind's eye to catch spelling errors,
yours and others, your spelling skills will not
improve very much, if at all.
Godzilla! Queen Of Lexiconia And Friend To Jack Rabbits.
------------------------------
Date: Wed, 05 Sep 2001 04:47:53 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to I background a process and not wait for it.
Message-Id: <3B95E6B9.247B3832@earthlink.net>
John J. Trammell wrote:
>
> On Thu, 30 Aug 2001 23:52:58 +0800, John Hennessy wrote:
> > Is there a simple way to do the equivalent of a system call but not
> > wait for it to finish.
> > I am not too interested in the success of the backgrounded task but
> > I must be able to move onto the next foreground command in the
> > script.
>
> This is answered in Perl FAQ 8: "How do I start a process in
> the background?"
The faq only provides one single solution:
system("cmd &");
which only works when the shell is sh [the bourne shell] or something
enough like it to recognize "&" to mean start-in-the-background. It
doesn't work if your shell is different -- eg, this fails when the shell
is cmd.exe or command.com, etc. [this is not to say it invariably fails
on dos/windows -- since if you're running cygwin, your shell might be
sh]
It also suggests fork, which, on mswin, is simulated with threads... so
the standard fork/exec that you might want to do, won't work.
A *slightly* more portable way to run a command in the background is:
use IPC::Open3;
# since it's in the background, it shouldn't have a stdin.
# instead, we make it try and read from /dev/null, or equivilant.
open(DEVNULL, "<", ($^O =~ m/win/i) ? "nul" : "/dev/null");
# create "cmd" process in the background.
# don't give it anything to read from, but do have it print
# it's stdout and stderr to our stdout and stderr.
my $pid = open3("<&DEVNULL", ">&STDOUT", ">&STDERR", "cmd");
# do stuff here while "cmd" is running in the background.
# wait for "cmd" to exit.
if( waitpid $pid, 0 ) {
my ($sig, $val) = ($?%256, $?/256);
die "cmd died from signal $sig\n" if $sig;
die "cmd exited with code $val\n" if $val;
} else {
die "waitpid(cmd) failed: $!";
}
If you're not interested in the success or failure of the backgrounded
program, then replace the waitpid stuff with a signal handler to clean
up zombies [see perldoc perlipc, the REAPER stuff... just remember to do
it *before* any/all calls to open3].
The reason I suggest that open3 might be portable, is that in the
source, there's conditionals which test if $^O is os2 or MSWin32, and if
so, try to create a child process in a different [not fork()] manner.
Does anyone has experience in using open3 to create a background process
on windows? It'd be nice to know. I'd hate for us to be limited to
using system("start", ...) and Win32::Process.
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1694
***************************************