[6581] in Perl-Users-Digest
Perl-Users Digest, Issue: 206 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 31 00:15:15 1997
Date: Sun, 30 Mar 97 21:00:22 -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 Sun, 30 Mar 1997 Volume: 8 Number: 206
Today's topics:
? about require and memory consumption (David Alan Pisoni)
ANNOUNCE: Net::Bind 0.01 (Kevin Johnson)
Re: calling a Perl script from inetd (Nathan V. Patwardhan)
Free Winfaxpro Software (james spearheart)
Re: How to convert .dbm to (.pag .dir) <rootbeer@teleport.com>
Re: Microsoft Running Naked Through the Streets? (Mark)
Re: NewbieQ: flow control while in while loop <blongwor@student.umass.edu>
Re: Perl mishandles some multidimensional array referen < hansm@icgned.nl>
Re: PERL mutiplications (Tad McClellan)
Re: PERL mutiplications (Tad McClellan)
Question on Strings [HELP] (BrettH3522)
Re: Question on Strings [HELP] <dalewis@cs.buffalo.edu>
Re: Robert Braver Kills 39 People (Igor Chudov)
running a loop foreach $ARGV? <blongwor@student.umass.edu>
Re: running a loop foreach $ARGV? (Nathan V. Patwardhan)
Re: running a loop foreach $ARGV? <dalewis@cs.buffalo.edu>
Running CGI Scripts <amerar@unsu.com>
Re: Running CGI Scripts (Tad McClellan)
Re: Smarter indexing algorythm (David Alan Pisoni)
Re: Why is no subscripting allowed in custom sort routi (Andrew M. Langmead)
X11::Fvwm 0.2 uploaded to PAUSE (Randy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 30 Mar 1997 20:19:59 -0800
From: david@cnation.com (David Alan Pisoni)
Subject: ? about require and memory consumption
Message-Id: <david-3003972019590001@prokofiev.cnation.com>
Keywords: Perl require use memory
Hello,
I have a nagging question that has been on my mind for quite some time,
but that the man pages and FAQ do not seem to address. The answer seems
implicit in the man pages, but is never explicitly stated (and so I may
have inferred it incorrectly.)
My question is, when one uses 'require' (or 'use') in one package (i.e.,
main), and also in another (i.e., another module 'require'd by main), does
perl load that code module into memory a second time? Or (as I imagine it
would) does it simply skip the repeat 'require' operation (in the case of
'use', import the requested exports into the current namespace from the
file that has already been loaded previously.) This is a curioso to me
because I have a module which acts as a subclass to a selected DB module.
It of course requires that DB module by itself, assuming that the calling
program did not. But sometimes the calling program needs to use the DB by
itself (without said subclass), and so it 'use's it as well.
Thank you for answering my burning curioso,
David Pisoni, System Administrator
CyberNation, LLC -- Web Design for the Next Milennium
david@cnation.com - http://www.cnation.com/
310/656-3450 - 310/656-3453 (fax)
------------------------------
Date: 31 Mar 1997 00:40:33 GMT
From: kjj@primenet.com (Kevin Johnson)
Subject: ANNOUNCE: Net::Bind 0.01
Message-Id: <5hn161$3pi$1@nadine.teleport.com>
The first release (0.01) of Net::Bind has been posted to CPAN under my
author id (KJOHNSON) and name (Kevin_Johnson).
Net::Bind provides a perl interfaces to various files related to the
bind DNS daemon. For this alpha release, there is only an interface
for /etc/resolv.conf data. Future releases will include interfaces
for named.boot files, zone files, bind dump files, and the new
named.conf file (ala bind-8.x). I expect to provide these other
interfaces before it goes to beta release.
If you are interested in the future capabilities of this module,
please take a look at the current minimal implementation provide
feedback.
The module is in alpha release. Think twice about using it to modify
important data.
The method interface is currently in an evaluation phase. I expect to
make interface changes that are not backward compatible before it goes
to beta release. I'm providing it now to get input on the interface.
The current version has been tested against 5.003_24.
Refer to the provided README file for additional information.
I am keenly interested in feedback from folks regarding the method
interface. I want to make sure it's workable before I start chomping
on the other larger file interfaces.
Please report any bugs/suggestions to <kjj@pobox.com>.
Copyright (c) 1997 Kevin Johnson <kjj@pobox.com>
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.
--
thx,
kjj@pobox.com http://www.pobox.com/~kjj/
------------------------------
Date: 31 Mar 1997 01:41:09 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: calling a Perl script from inetd
Message-Id: <5hn4nl$lbr@fridge-nf0.shore.net>
Jairo A. Medina (phillip.green@citicorp.com) wrote:
: Has anybody done something like that?, Can anybody tell me how to get
: the socket handle once the connection is made and inetd call my script?
Hmm, interesting linewrap. Looks like the foot-diagram for the foxtrot
(or maybe even the lambada), and rather difficult to read. :-(
You might look at perlipc.pod, which has an entire section devoted to socket
clients/servers, or _Programming Perl_, Second Edition, which also has a
section devoted to the same, based on perlipc.pod.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 30 Mar 1997 23:29:24 GMT
From: napboule@geocities.com (james spearheart)
Subject: Free Winfaxpro Software
Message-Id: <5hmt0k$9gr@news.atlantic.net>
http://208.212.49.94/free/
------------------------------
Date: Sun, 30 Mar 1997 16:23:09 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Alex Chkliar <concord@cam.org>
Subject: Re: How to convert .dbm to (.pag .dir)
Message-Id: <Pine.GSO.3.96.970330162130.14672A-100000@kelly.teleport.com>
On Sun, 30 Mar 1997, Alex Chkliar wrote:
> Is there a way to convert .dbm to (.pag .dir)?
Do you mean by reading in entries one at a time from the old file and
writing them out one at a time to the new file? (Gee, that sounds like a
one-liner! :-) Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Mon, 31 Mar 1997 04:20:44 GMT
From: (Mark)
Subject: Re: Microsoft Running Naked Through the Streets?
Message-Id: <333f3b46.16910636@news.ntr.net>
On Sun, 30 Mar 1997 22:22:56 GMT, DeathToSpam@dev.null.com (Lee)
wrote:
>I think its time to retire to some remote island....before this
>nightmare really begins<s>
>
>nvp@bill-graham.nfic.com (Nate Patwardhan) wrote:
>
>@>-->---I R A Aggie (fl_aggie@hotmail.com) wrote:
>@>-->---James> In article <5hc0e7$ger$1@bob-marley.nfic.com>,
>nvp@bill-graham.nfic.com
>@>-->---James> (Nate Patwardhan) wrote:
>@>-->---
>@>-->---+ I've heard rumours that Microsoft is running naked through
>the
>@>-->---+ streets. Well I suppose it's their perogative, as they own
>the
>@>-->---+ streets they're running naked through.
>@>-->---
>@>-->---James> Hey, as long as no one forces me to watch Bill G. run
>nekkid thru
>@>-->---James> the streets...
>@>-->---
>@>-->---It's rumoured that running through the streets will become the
>@>-->---industry standard. :-)
>@>-->---
>@>-->---Nate Patwardhan
>@>-->---nvp@nfic.com
>@>-->---nvp@shore.net
>@>-->---
>
>--Lee
>
>Internet/Intranet Counsulting and Design:
>http://www.designwest.com
>Nurses' Call:
>http://www.nurse.org/Nurses_Call/
Funny,
Was Microsoft also yelling 'Freeshow' as it ran thru the
streets nekkid?
--
Mark <mark@ntr.net>
Please don't sue my boss because you don't
understand the concept of free speech.
*Pain is something funny that happens to YOU*
------------------------------
Date: Sun, 30 Mar 1997 21:33:36 -0500
From: Brett Longworth <blongwor@student.umass.edu>
Subject: Re: NewbieQ: flow control while in while loop
Message-Id: <333F227F.242B@student.umass.edu>
Tad McClellan wrote:
>
> Brett Longworth (blongwor@student.umass.edu) wrote:
> : Hello,
>
> : Sorry about the confusing subject line, I couldn't think of a better way
> : to explain my problem quickly.
>
> : I know this is a simple one, but I can't seem to find the answer
> : anywhere. While using a while loop to grab stuff I want from a text
> : file, I'd like to try to grab a line that may or may not occur between
> : two matches of a regex a few lines apart. If it is there, it should be
> : associated with the regex a few lines before it, if it's not, it
> : shouldn't be.
>
> : Bleah, that previous paragraph is longer than my problem. Right now,
> : I'm trying to append the "in-between" line to the same variable that
> : contains the first line, and then sort it all out later. If anyone
> : understood my poor explanation of what I'm trying to do, a push in the
> ^^^^^^^^^^^^^^^^^^^
> : right direction or suggestion of a good consruct to get this done would
> : be great.
>
> Why not just supply some sample data, and tell us what you
> want to extract from it...
>
> Code is much easier to understand than English ;-)
Kinda scary- I've been using perl for a few weeks now, and I find myself
explaing things outside perl in terms of looping constructs and
regexes. Anyway, here's the solution that a kind soul helped me get to,
in case anyone is curious.
-Brett
while (<>) {
if (/\s+\w{3,4}\s+[<>]?\d{1,5}\.{2,}/) {
$whatwhere[$a++] = $_;
while (($_ = <>) && !/\s+\w{3,4}\s+[<>]?\d{1,5}\.{2,}/)
{
if (/\/product=/) {
#do what you need with inbetween string
$_ =~ s/\n//g;
$whatwhere[$a - 1] .= $_;
print "$whatwhere[$a - 1]\n";
last;
}
}
}
elsif ($_ =~ /\d+\s+[atgc]{10,}/) {
$sequence .= $_;
}
}
------------------------------
Date: 31 Mar 1997 01:24:12 GMT
From: Hans Mulder< hansm@icgned.nl>
Subject: Re: Perl mishandles some multidimensional array references???
Message-Id: <5hn3ns$8b5@news.euro.net>
Randal Schwartz <merlyn@stonehenge.com> wrote:
> Again, the easiest way to get the syntax is to start with the seven
> kinds of variable access, and what they can contain:
> $S = scalar
> $L[scalar] = scalar
> $H{scalar} = scalar
> @L[list] = list
> @H{list} = list
> %H = list (key/value pairs)
You forgot the seventh:
$H{list} = scalar
Hope this helps,
--
HansM print 1->[@{!@!}=q\Just another Perl hacker,\,<=>]
------------------------------
Date: Sun, 30 Mar 1997 18:09:09 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: PERL mutiplications
Message-Id: <5bvmh5.pl.ln@localhost>
Steven Sajous (steve@golf.com) wrote:
: I have two variables in a mutliplication as such:
: $total = $var1 * $var2
: with:
: $var1 = 19.95
: $var2 = 1
: I get $total = 19.950000000000000297 or some other garbage
This is a consequence of how numbers are stored in computers.
Perl is just passing through this limitation of the hardware...
(as would C, C++, Pascal, anything else... ;-)
: How do I just get $total = 19.95?
$total = sprintf("%5.2f", $total);
or
$total = sprintf("%5.2f", $var1 * $var2);
: Please e-mail me at steve@golf.com.
Please read the newsgroup at comp.lang.perl.misc
: Thanx
You're welcome.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Sun, 30 Mar 1997 21:35:34 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: PERL mutiplications
Message-Id: <6ebnh5.a56.ln@localhost>
I, myself (tadmc@flash.net) wrote:
: Steven Sajous (steve@golf.com) wrote:
: : I have two variables in a mutliplication as such:
: : $total = $var1 * $var2
: : with:
: : $var1 = 19.95
: : $var2 = 1
: : I get $total = 19.950000000000000297 or some other garbage
^^^^^^^^^^^^^
When I use paper and pencil to do 1/3, I get:
.33333333333333333333333333333333333333333333333333333333333333333333
or some other garbage. ;-)
Cannot represent 1/3 exactly in a base 10 number..
: This is a consequence of how numbers are stored in computers.
: Perl is just passing through this limitation of the hardware...
It is, more accurately, a consequence of using base 2 numbers...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 31 Mar 1997 04:01:04 GMT
From: bretth3522@aol.com (BrettH3522)
Subject: Question on Strings [HELP]
Message-Id: <19970331040100.XAA10181@ladder01.news.aol.com>
Is there any way to convert a string (of numbers to an integer). If not,
is there a way to convert an integer into a string?
Also, one last question. I am running Windows NT 4.0 with IIs server. I
can go into the registry and add a value in
/System/Services/W3SVC/Parameters/ScriptMap to make perl.exe execute
everytime a script is called. I heard using the perlis.dll is better, but
when I change the value to point to perlis.dll, it does not work. I
restart the server and go into netscape navigator 3.0 on another computer,
instead of calling the perl script, it thinks I want to download it. Any
suggestions? I would appreciate it if you could e-mail me at
bretth3522@aol.com
Thank You, Brett Hamlin
------------------------------
Date: Sun, 30 Mar 1997 23:12:03 -0500
From: Douglas Lewis <dalewis@cs.buffalo.edu>
To: BrettH3522 <bretth3522@aol.com>
Subject: Re: Question on Strings [HELP]
Message-Id: <333F3993.4ED2BAE9@cs.buffalo.edu>
BrettH3522 wrote:
>
> Is there any way to convert a string (of numbers to an integer). If not,
> is there a way to convert an integer into a string?
Convert a string to an integer?
$string = '123456';
$number = $string + 0;
Convert a number to a string? (if you must...)
$str = sprintf("%d", $number);
Hope that helps
Douglas Lewis
no_nick@ix.netcom.com
------------------------------
Date: 31 Mar 1997 03:20:02 GMT
From: ichudov@galstar.com (Igor Chudov)
Subject: Re: Robert Braver Kills 39 People
Message-Id: <5hnah2$3nq@mercury.galstar.com>
Josh McCormick, tell us how you sued Robert Braver.
igor
the one and only real true kibo (kibo@dhp.com) wrote:
* -----BEGIN PGP SIGNED MESSAGE-----
*
* On Thu, 27 Mar 1997 16:52:56 -0600 in article <imp-2703971652560001@206.109.6.138> posted to news.admin.censorship, impLAnt <imp@yoyo.mil> wrote:
*
* > Seems that well-known cancel forger and USENET vigilante Robert Braver
* > <http://www.firmware.com/ads.htm>(root@ohww.norman.ok.us) may be
* > responsible for 39 cult members killing themselves, out of total
* > frustration that they couldn't deliver their message. See:
*
* > http://spam.ohww.norman.ok.us/spam_notices/junjul96.htm
*
* > Which takes us to:
*
* > http://spam.ohww.norman.ok.us/spam_notices/19960620.13.html
*
* > Mr Braver therein brandishes his forged cancellation of
* > "rep@heavensgate.com" (deceased)'s messages like a hunting trophy. It is
* > impossible to know how many more Heaven's Gate messages Robert has
* > cancelled; since October of '96 he has refused to acknowledge or disclose
* > the true depth of his criminal USENET activities and censorship.
*
* > A tangential link to these 39 deaths has been drawn. Hopefully this will
* > lead to Mr Braver's extradition from his Norman, OK compound, where he
* > lives in seclusion with his wife/sister Lizz, to face a Federal grand jury
* > regarding his involvement in this case.
*
* There's no question that Robert Braver and his sister/wife Lizzie
* are guilty of many federal crimes, including trafficking in child
* pornography and Usenet forgery. Where is the FBI when we need it?
*
* > -iMp
* > news.admin.censorship
*
* "ohww" stands for "Oakbrook Home for Wayward Wonks", an obviously phoney
* domain. Robert Braver is really rbraver@firmware.com, the proprietor of
* Micro Firmware, Inc., 330 W. Gray St., Ste 120, Norman, OK 73069-7111,
* (405) 573-5501. He is also responsible for the several waves of forged
* cancels coming from Cottagesoft and Internet Oklahoma last year.
*
* Timothy McVeigh had breakfast with the Braver's before blowing
* up the Federal office building later that day.
*
* Josh McCormick sued the Bravers for $2000 in small claims court; he
* won, but he's still waiting to collect.
*
* I am the only true <A HREF="http://www.dhp.com/~kibo">Kibo</A>.
* Finger me for my PGP public key. Check out my home page for the coolest
* way to vote on new newsgroup proposals or to issue Usenet cancels.
*
* -----BEGIN PGP SIGNATURE-----
* Version: 2.6.2
*
* iQCVAwUBMz06ZqlPvImbzLKZAQFJ/AP6A9Y05N/8UK7wIXyJBklch8qzYFsDMF4Y
* 0umoYfJC9UtQ8yEtKsSsbyotlq5mIipr8Y1vHFiYrgYj4tNTDy1qZlB9i3bRsrnV
* CKjNvLFKg8P/U9qDx/XbO2mteQ1AWJgF4ta3ZB2fOYTIZbrfV0stpG280FQ8HdFP
* 1nNtcks6kdc=
* =yEpl
* -----END PGP SIGNATURE-----
------------------------------
Date: Sun, 30 Mar 1997 21:51:01 -0500
From: Brett Longworth <blongwor@student.umass.edu>
Subject: running a loop foreach $ARGV?
Message-Id: <333F2693.1E18@student.umass.edu>
Hello again,
I need to do a bunch of stuff with every file from the command line.
I've tried a foreach loop like:
foreach $ARGV (@ARGV) {
while (<>) {
#stuff to do to each file
}
}
which of course gets to the inner loop and runs through all the lines in
all files...
and also a more convoluted construct:
while (<>) {
$file = $ARGV;
while ($file = $ARGV) {
#stuff
}
}
which does the same thing but worse, because it becomes an endless loop.
This seems like a no-brainer, but if I just can't figure out why the
second one doesn't work and how I can get either of them to work.
Perhaps after a few more cups of coffee... Anyway, if someone could
point me in the right direction, I'd be really greatful.
Thanks!
-Brett
------------------------------
Date: 31 Mar 1997 03:31:43 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: running a loop foreach $ARGV?
Message-Id: <5hnb6v$sl9@fridge-nf0.shore.net>
Brett Longworth (blongwor@student.umass.edu) wrote:
: I need to do a bunch of stuff with every file from the command line.
: I've tried a foreach loop like:
[snip]
One method using @ARGV might be (this doesn't write any files):
#!/usr/local/bin/perl -w
foreach (@ARGV) {
open(FILE, "$_") || die("Can't open $_: $!");
while(<FILE>) {
print;
}
close(FILE);
}
You might also try the Getopts stuff - pretty useful.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Sun, 30 Mar 1997 23:06:29 -0500
From: Douglas Lewis <dalewis@cs.buffalo.edu>
Subject: Re: running a loop foreach $ARGV?
Message-Id: <333F3845.16A02EBA@cs.buffalo.edu>
Nathan V. Patwardhan wrote:
>
> Brett Longworth (blongwor@student.umass.edu) wrote:
>
> : I need to do a bunch of stuff with every file from the command line.
> : I've tried a foreach loop like:
> [snip]
>
> One method using @ARGV might be (this doesn't write any files):
>
> #!/usr/local/bin/perl -w
>
> foreach (@ARGV) {
> open(FILE, "$_") || die("Can't open $_: $!");
> while(<FILE>) {
> print;
> }
> close(FILE);
> }
I would consider: (If you don't really care what info comes from
what file
while (<>)
{
# whatever
}
or the follwing (If you are interested in what file you are working on)
my @PASSED_ARGV = @ARGV;
foreach $FILE (@PASSED_ARGV)
{
@ARGV = ($FILE);
while (<>)
{
# whatever
}
}
Douglas Lewis
no_nick@ix.netcom.com
------------------------------
Date: Sun, 30 Mar 1997 20:36:42 -0600
From: Arthur Merar <amerar@unsu.com>
Subject: Running CGI Scripts
Message-Id: <333F233A.3E06@unsu.com>
Hello, I need some help. I am dealing with my first CGI script. This
script simply prints out some GIF's on my homepage, but it is not
working.
I am trying to get it working locally on my Linux drive first. When I
enter the script name from the prompt, the script 'seems' to work. It
displays the code from my HTML document on the screen.
Next I put the command <!--#exec cgi="/root/www/cgi-bin/counter.cgi"-->
in my homepage, but nothing happens. No GIF's, no nothing.
I am trying to figure out what I am doing wrong, if it is my setup or my
script or something. I thought someone with more CGI experience than me
can could help me out.
I appreciate any help.
Thanks,
Arthur
amerar@unsu.com
http://www.unsu.com
------------------------------
Date: Sun, 30 Mar 1997 21:40:31 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Running CGI Scripts
Message-Id: <fnbnh5.a56.ln@localhost>
Arthur Merar (amerar@unsu.com) wrote:
: Hello, I need some help. I am dealing with my first CGI script.
You are in the wrong newsgroup for this question Arthur.
This newsgroup is for perl questions. This time, you have a CGI
question. The newsgroup for asking about that would be:
comp.infosystems.www.authoring.cgi
: This
: script simply prints out some GIF's on my homepage, but it is not
: working.
: I am trying to get it working locally on my Linux drive first. When I
: enter the script name from the prompt, the script 'seems' to work. It
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: displays the code from my HTML document on the screen.
This is a dead giveaway that perl is doing the Right Thing.
Hence, this is not a perl problem, and therefore, does not
belong in the perl newsgroup.
: Next I put the command <!--#exec cgi="/root/www/cgi-bin/counter.cgi"-->
: in my homepage, but nothing happens. No GIF's, no nothing.
: I am trying to figure out what I am doing wrong, if it is my setup or my
: script or something. I thought someone with more CGI experience than me
^^^^^^^^^^^^^^^^^^^
: can could help me out.
Since this is the perl newsgroup, you might expect to find folks with
more _perl_ experience here.
To find folks with more CGI experience, try a newsgroup that is in
some way connected to CGI scripting (this newsgroup is not).
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Sun, 30 Mar 1997 20:01:55 -0800
From: david@cnation.com (David Alan Pisoni)
Subject: Re: Smarter indexing algorythm
Message-Id: <david-3003972001550001@prokofiev.cnation.com>
Hello,
I'm writing this to follow up on my application, to those who are
interested. I received a handful of useful suggestions, tried various
things, and came up with my present application. Here is what it does
differently :
* At start, sort all zips by lattitude.
* Next, cache zip/state mappings (i.e., which zips to we look up for
state X), RETAINING above sorted order (this step already existed, I
simply made sure it kept the sorting order.
* cleaned up placements of my's, etc.
* As the inner loop runs, before it even runs the proximity
algorythm, it firsts test to see if the lattitudes being compared are
within 1.5 degrees (roughly 100 miles) of each other. If it is less, then
it calls 'next'. If it is more, then it calls 'last' (since the zips are
sorted by lattitude already, this works.) If it is within lattitude
range, then do the proximity test (as stated below.)
This has sped up the process considerably, and I estimate the entire
program will take me less than 24 hours to complete. This is a
considerable improvement over 13.5 days! :-} Since this program only
needs to be run very infrequently (as ofter as I get an updated zip code
database for it), this is more than acceptable.
Oh, of note, I experimented with caching proximity calculations so that
the same lookup would not need to be processed more than once, but this
turned out to be a bad idea, because the process started eating up so much
memory that it slowed to a crawl as a result of overswapping. It didn't
even last through Alaska (obviously, the Northernmost state.)
Anyway, thank you for all of your ideas. I appreciate it!
David Pisoni
P.S. - If you wonder why I chose lattitude over longitude as my sorting
criterion, then I recommend that you take a close look at the lines on a
globe. :-}
In article <david-2603971557470001@prokofiev.cnation.com>,
david@cnation.com wrote:
>Hello,
>
>I recently wrote a program that takes a database of zip codes with their
>geographic coordinates and creates an index database listing each zip code
>and the six closest zip codes. The trouble is, it looks like it might
>take as long as ten days to run! I was wondering if anyone had any ideas
>how I could tighten the algorythm so that it would not take as long. Here
>is my process (in perly English):
>
>Outer Loop : foreach $zip (all zip codes) {
> Inner Loop : foreach $testzip (all zip codes in current state AND
>bordering states of $zip) {
> next if ($testzip == $zip);
> $prox = distance between $zip and $testzip (in miles, if you care)
> for ($pos=0;$pos<=5;$pos++) {
> if ($prox < distance between $pos closest zip and $zip
>(already cached) { splice $testzip into list at $pos; pop list; last; }
> } # END for loop
> } # END inner loop
> Store list of 6 closest zip codes in index database
>} # END outer loop
>
>The reason this algorythm is so slow is that for each zip code it tests
>the distance between itself and EVERY zip code in it's home state, and all
>the states bordering. I could not come up with a better solution to this
>problem, though I put a lot of thought into it. The algorythm could be
>slightly tightened if each zip code placed itself in the proximity list of
>all the zip codes on it's list, but the difference would probably only be
>slight. The real bottleneck is the long list of comparisons.
>
>Can anyone think of a more expedient methodology for this process?
>
>Thank you for your help,
>David Pisoni, System Administrator
>CyberNation, LLC -- Web Design for the Next Milennium
>david@cnation.com - http://www.cnation.com/
>310/656-3450 - 310/656-3453 (fax)
David Pisoni, System Administrator
CyberNation, LLC -- Web Design for the Next Milennium
david@cnation.com - http://www.cnation.com/
310/656-3450 - 310/656-3453 (fax)
------------------------------
Date: Mon, 31 Mar 1997 02:22:01 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Why is no subscripting allowed in custom sort routines?
Message-Id: <E7vyKp.1L2@world.std.com>
friedman@medusa.acs.uci.edu (Eric D. Friedman) writes:
>Consequently the following does not work:
>use strict;
>my @foo = qw( cat mouse dog fish bird squirrel zebra );
>my $routine = sub { $a cmp $b };
>my @sorted_foo = sort &$routine @foo;
>My question: how can I write an anonymous sort subroutine that is NOT
>an in-line BLOCK? I want to be able to create a reference to a default
>sort routine which I could then change if one condition or another is
>met.
One suggestion is:
my @sorted_foo = sort { &$routine } @foo;
But it is a little slower because there is an extra subroutine
call. (The block calls the subroutine by reference)
In "Programming Perl" 2ed, it says that the scalar can contain a
reference to a subroutine, so maybe its just another case of the
implementation needing to catch up to the documentation, and someday
you will be able to just say
my @sorted_foo = sort $routine @foo;
Another idea is to keep the name of the sort subroutine fixed, and
eval a string that creates a subroutine of that name at runtime.
$sortsub = $opt_s || '$a cmp $b';
eval "sub by_specified_criteria { $sortsub }";
die $@ if $@;
foreach (sort by_specified_criteria @dirs) {
# do stuff
}
Even your idea of eval'ing the entire sort statement could be made a
little easier by taking the sorting out of the for loop.
if ($opt_s) {
@sorted_dirs = eval "sort $opt_s \@dirs";
}
else {
@sorted_dirs = sort @dirs; # same as 'sort { $a cmp $b } @dirs'
}
foreach (@sorted_dirs) {
# do stuff
}
--
Andrew Langmead
------------------------------
Date: 31 Mar 1997 00:40:07 GMT
From: randy@byz.org (Randy)
Subject: X11::Fvwm 0.2 uploaded to PAUSE
Message-Id: <5hn157$3pd$1@nadine.teleport.com>
Keywords: fvwm perl tk x11
Fri Mar 28 18:24:21 MST 1997
Version 0.2 of X11::Fvwm has been uploaded to PAUSE, and should propagate to
CPAN servers over the next few days.
Information on this package may be found at:
http://www.byz.org/~randy/perl/X11::Fvwm
Please note that the links to download the package will take a day or two
before functional, waiting for CPAN sites to receive the package from
PAUSE.
This is the second alpha release. Not all planned features are in, not all
data packet types are yet correctly identified and dissected. The interface
style and overall functionality are still subject to drastic change before
this moves into beta. Changes in this version are list below.
IMPORTANT: This version makes heavy changes to the packet handler interface
and use of Tk. Handlers now receive the object reference to the X11::Fvwm
object as their first argument, and Tk functionality is sub-classed into
X11::Fvwm::Tk, to make it easier to add other GUI packages (such as Xforms)
at a later date.
>From the README file for 0.2:
X11::Fvwm version 0.2 (alpha 2)
WHAT IS IT?
This is a Perl 5 extension to simplify writing Fvwm2 modules in Perl 5. Not
only in Perl 5, but with the Tk extension as your GUI library!
This requires fvwm 2.0.45 or better, and perl 5.002 or better. It is very
highly recommended that you also install the latest version of Tk (which is
Tk400.202 as of this writing), also available from CPAN.
WHAT DOES IT DO?
Fvwm2 has a very well-defined module API, to allow the brunt of non-core
window-manager work be done by external modules. X11::Fvwm is a layer over
this interface, allowing you to use Perl rather than C as the language for
developing these modules.
When fvwm launches a module, it sets up file descriptors for two-way
communication, and proceeds to occassionally broadcast data packets to
those modules that have asked to receive the given data type. The modules,
in turn, can send commands back to fvwm, including requests for more (and
more specific) data, operation on windows managed by fvwm, etc.
PROBLEMS/BUG REPORTS
Please send any reports of problems or bugs to randy@byz.org. I wouldn't
mind a short note to know that you're using this, just so I can justify its
continued development :-).
CREDITS AND LICENSES
This package is copyright (c) 1997 by Randy Ray (randy@byz.org) and may be
distributed under terms of the Artistic License used to cover Perl itself.
See the file Artistic in the distribution of Perl 5.002 or later for details
of copy and distribution terms. All rights reserved.
>From the Changes file for 0.2:
* Changed the invocation of handlers to include a reference to the X11::Fvwm
object as the first parameter. Otherwise, handlers have no access to the
object unless the object is global or the handler is created as a closure.
* Removed the Tk references in Fvwm.pm, so that X11::Fvwm acts as a base
class for the API. Fvwm/Tk.pm (X11::Fvwm::Tk) now is a subclass of X11::Fvwm
with the new() and eventLoop() methods overloaded. Also adds one new
instance variable and a method to access it by. This should simplify adding
other GUI widget sets, such as Xforms.
* Put in some simple default handlers in Fvwm/Defaults.pm (package
X11::Fvwm::Defaults), that can be used if they meet the developer's needs.
So far, only M_ERROR seems to lend itself to such a default handling.
* X11::Fvwm, X11::Fvwm::Tk, X11::Fvwm::Defaults and PerlTkWL are all -w and -T
clean.
* Makefile.PL now handles the demos as *.PL files, which allows them to be
extracted by perl itself, which results in an invocation line based on
the user's configuration of perl. Also checks for a usable version of
the Tk extension.
Randy
--
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
randy@byz.org http://www.byz.org/~randy/
"Sometimes I think the surest sign that intelligent life exists elsewhere in
the universe is that none of it has tried to contact us." --Calvin
------------------------------
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 206
*************************************