[17943] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 103 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 19 21:05:27 2001

Date: Fri, 19 Jan 2001 18:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979956307-v10-i103@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 19 Jan 2001     Volume: 10 Number: 103

Today's topics:
        ActiveState PerlDev GUI Debugger - can't get to work on petermoss314@my-deja.com
        Associative Array of Arrays <srdjans@digitalpersona.com>
    Re: Associative Array of Arrays <time4tea@monmouth.com>
        calling a script within a script??? <fsburrow@georgefox.edu>
        CGI Problem <dogansmoobs@softhome.net>
    Re: FAQ 9.15:   How do I decode a CGI form? <joehecht@code4sale.com>
    Re: Fork stability on ActivePerl (Tim Hammerquist)
    Re: Jobs: Senior Software Engineer (Mark W. Schumann)
    Re: MIME Lite Problem (David Efflandt)
        Perl  - Bytecode, Compile to C, Perl2EXE  jgore@home.com
    Re: Perl  - Bytecode, Compile to C, Perl2EXE (Abigail)
    Re: Perl OOP questions (Tim Hammerquist)
    Re: Perl script problem <krahnj@acm.org>
    Re: Perl script problem (Tad McClellan)
    Re: Random Numbers with a Twist <rob@frii.com>
    Re: Random Numbers with a Twist (Abigail)
    Re: Suppressing stderr on `` commands <james@NOSPAM.demon.co.uk>
    Re: Suppressing stderr on `` commands <flavell@mail.cern.ch>
    Re: Suppressing stderr on `` commands (Tad McClellan)
        url parsing <cam@home.com>
    Re: url parsing <juex@deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 20 Jan 2001 01:53:38 GMT
From: petermoss314@my-deja.com
Subject: ActiveState PerlDev GUI Debugger - can't get to work on Win2k/IIS 5.0
Message-Id: <94ar30$j9j$1@nnrp1.deja.com>

I am having trouble getting the perl GUI debugger in ActiveState's
PerlDev kit to launch from a an IIS 5.0 site.

I have a win2k box running IIS 5.0 with CGI perl pages setup and I
would like to debug them while I am logged in at the console on that
box.
IIS is configured with an ISAPI applicaiton mapping like
C:\Perl\bin\Perl.exe "%s" %s for .pl files

I changed the ISAPI mapping to
C:\Perl\bin\Perl.exe -d "%s" %s to trigger the debugging
and setup for local debugging.

The problem is that the perldb.exe launches but not on the console.
I made sure that IISAdmin service, MSFTPSvc, and IIS (and any other IIS
type service) all run as System with interact with console checked in
the services area.

The problem is that IIS always runs under another users context like
IUSR_machinename then it launches PerlDB.exe as that account not in the
same console.

I also tried do it remotely off another server, changing the ISAPI
mapping again to perl.exe -d "%s" %s and configuring it to try to
connect TCP on port 2000 to another box that was set up as the listener
with that perlsocket service, and I also configured that service to run
as system with "allow to interact with console checked".  Again, the
loading of scripts on the web server did indeed trigger the PerlDB.exe
executible on the listening machine, but it was not visible on the
console.Set the PERLDB_OPTS environment variable as specified in the
documentation.  And the Web Server does connect back to client debugger
machine and launch PerlDB.exe - i.e. when I go to a .pl page in the web
browser, the browser appears paused - on the debug listening box a
connection is made to the debugging port 2000.  And PerlDB appears in
the process list on the remote machine doing the debugging.  However,
the PerlDB does not come up with a window.

I believe it is because of the ability of the Perlsocket listener to
interact with the desktop, but I already set that service to run as
system with ability to interact with the desktop.



Just wondering if you had any tips.  Could not find much on the
newsgroups or in your FAQs.  I was going to try the whole thing with
Apache on Win32 next.


Also tried making all the requisite Win2k services IISAdmin, W3Svc, and
other IIS services run as my same account too, but to no avail.






Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 19 Jan 2001 16:39:32 -0800
From: "Srdjan Sobajic" <srdjans@digitalpersona.com>
Subject: Associative Array of Arrays
Message-Id: <94amo5$1j8o$1@nntp1.ba.best.com>

Hello,

I am trying to create an associative array where a particular key would
reference an array.
Basically as the code below shows, I would like to load some values into an
array, which can
be then looked up in the associative array:

Something like:

$a{$b}[$c] = $d;

(The loading of this array is the first while loop below).

What I would like to do is sort on the keys of %a (the $b's above),
and then print out all the elements of the corresponding (regular) array
(ie. all the $d's stored at location $a{$b}[$c]) for every key $b.

Since the size of the array corresponding to any key is variable length,
I need some mechanism to either iterate over that array (ie a particular
$a{$b})
or find the length of the array stored at $a{$b}.

Using the foreach syntax below doesn't seem to work, and neither will
scalar($a{$b}) or $#a{$b}. The best I have come up with is to do my own
counting, and create a second associative array %nrofelements, which is
initialized
as $nrofelements{$b} = (size of array). This works, but seems ugly.

If anybody has any ideas (I've searched through the articles on deja and my
newsserver)
on how to do this more elegantly, I would greatly appreciate them.

Thanks for reading!

Srdjan

----

open(CAPTURE, @ARGV[0]) || die "Cannot open file!";

while(<CAPTURE>) {
    chop;
    @line = split(';');
    @nodes = split(' ', @line[1]);
    for($i=0; $i<scalar(@nodes); $i++) {
        $curnet{@line[0]}[$i] = @nodes[$i];
   }
}

# This Doesn't Work! (probably obviously)
foreach (sort keys(%curnet)) {
    print($_, "\n");
    foreach $el ( [@$] curnet{$_}) {
        print($curnet{$_}[$el]," ");
    }
    print("\n");
}




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

Date: Fri, 19 Jan 2001 20:46:52 -0500
From: "James Richardson" <time4tea@monmouth.com>
Subject: Re: Associative Array of Arrays
Message-Id: <94aqod$sf8$1@slb7.atl.mindspring.net>


"Srdjan Sobajic" <srdjans@digitalpersona.com> wrote in message
news:94amo5$1j8o$1@nntp1.ba.best.com...
> Hello,
>
> I am trying to create an associative array where a particular key would
> reference an array.
> Basically as the code below shows, I would like to load some values into
an
> array, which can
> be then looked up in the associative array:
>
> Something like:
>
> $a{$b}[$c] = $d;
>
> (The loading of this array is the first while loop below).
>
> What I would like to do is sort on the keys of %a (the $b's above),
> and then print out all the elements of the corresponding (regular) array
> (ie. all the $d's stored at location $a{$b}[$c]) for every key $b.
>
> Since the size of the array corresponding to any key is variable length,
> I need some mechanism to either iterate over that array (ie a particular
> $a{$b})
> or find the length of the array stored at $a{$b}.
>
> Using the foreach syntax below doesn't seem to work, and neither will
> scalar($a{$b}) or $#a{$b}. The best I have come up with is to do my own
> counting, and create a second associative array %nrofelements, which is
> initialized
> as $nrofelements{$b} = (size of array). This works, but seems ugly.
>
> If anybody has any ideas (I've searched through the articles on deja and
my
> newsserver)
> on how to do this more elegantly, I would greatly appreciate them.
>
> Thanks for reading!
>
> Srdjan
>
> ----
>

There are many errors in this program! Some syntactical, some "social". My
code is always accused of being too verbose, but anyway...

> open(CAPTURE, @ARGV[0]) || die "Cannot open file!";

To reference a subscript of an array use $array[n].
When dying, please tell people why.

How about:

use strict;
my %curnet;
my $filename = shift;
die "No args Usage is blahblah\n" unless defined($filename);
open ( CAPTURE, $filename ) || die "Can't open $filename $!\n";

I actually prefer FileHandles over FILEHANDLES (see perldoc FileHandle )....

>
> while(<CAPTURE>) {
>     chop;

Use chomp in preference to chop. Its nicer to your input.

>     @line = split(';');

Split with a string is almost never what you want. Use a regular expression.

    my ( $key, $rest ) = split (/\;/);

>     @nodes = split(' ', @line[1]);
>     for($i=0; $i<scalar(@nodes); $i++) {
>         $curnet{@line[0]}[$i] = @nodes[$i];
>    }

    $curnet{$key} = [ split(/ /,$rest) ];

> }
>

(There are many other ways i imagine to do the same thing)

> # This Doesn't Work! (probably obviously)
> foreach (sort keys(%curnet)) {
>     print($_, "\n");
>     foreach $el ( [@$] curnet{$_}) {
>         print($curnet{$_}[$el]," ");
>     }
>     print("\n");
> }
>
>
#Assuming the keys are stringy
#If they are numbers use sort { $a <=> $b } keys (...)
foreach my $key ( sort ( keys ( %curnet ) ) ) {
    print "$key\n";
    print join(" ", @{$curnet{$key}}),"\n";
}

or replacing that last line

    my $ref = $curnet{$key};
    print join(" ", @$ref),"\n";

I'm assuming that you want to do other things with the data other than
sorting by the first field, cos otherwise all that splitting and joining is
a bit of a waste of time, and you might not get back exactly what you put
in.

You might also want to look at perldoc perldsc under the heading "Hash of
Arrays"

HTH

James





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

Date: Fri, 19 Jan 2001 14:50:37 -0800
From: "Sand" <fsburrow@georgefox.edu>
Subject: calling a script within a script???
Message-Id: <94agat$ein$1@news.chatlink.com>

Dumb question I know, but....

Does anyone know how to call a cgi script within another script??

Thanks,
Forrest




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

Date: Fri, 19 Jan 2001 23:52:47 GMT
From: Dogansmoobs <dogansmoobs@softhome.net>
Subject: CGI Problem
Message-Id: <94ak0c$dgk$1@nnrp1.deja.com>

I am having some trouble using the CGI module.  Well, take a look at my
code and tell me if there is something staring right in my face and I
just don't see it.

#!/usr/local/bin/perl -w
use CGI;
$query = new CGI;

# A message board system
# Also, most of this code will be used for the news posting system

# First open the message counter and get the number of messages already
there
# Check for a lockfile and open it (lock the counter)
while (-e "lockfile")
{ sleep(1); }
open (LOCKFILE, ">lockfile");

# Open the counter file, read the number, increment and write it back
if (open (COUNTERFILE, "msg_counter")) then ($numMsg = <COUNTERFILE>;)
else ($numMsg = 0;)
$numMsg++;
close (COUNTERFILE);

open (COUNTERFILE, ">msg_counter");
print (COUNTERFILE "$numMsg");
close (COUNTERFILE);

# Close the lockfile and delete it
close (LOCKFILE);
unlink ("lockfile");

# Get the variables and the values
$posterNick = $query->param('nick');
$posterEmail = $query->param('e-mail');
$postTime = gmtime();
$subject = $query->param('subject');
$message = $query->param('message');

# Open a new file and write the information
open (POSTFILE, ">$numMsg");
print (POSTFILE "$numMsg");
print (POSTFILE '0');
print (POSTFILE "$posterEmail");
print (POSTFILE "$posterNick");
print (POSTFILE "$postTime");
print (POSTFILE "$subject");
print (POSTFILE "$message");

# Close the file
close (POSTFILE);


This doesn't get anywhere and it dies with error messages complaining
that $query is undifined (it's not, $query = new CGI).  I know the
server supports the CGI module, but I have never used it before.  Thank
you.

 - Dogansmoobs
dogansmoobs@softhome.net
http://dogansmoobs.cjb.net/
If I were an infinite monkey, I'd make infinite toast.


Sent via Deja.com
http://www.deja.com/


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

Date: Sat, 20 Jan 2001 01:53:38 GMT
From: "Joe C. Hecht" <joehecht@code4sale.com>
Subject: Re: FAQ 9.15:   How do I decode a CGI form?
Message-Id: <Cc6a6.1624$ZB2.254493@paloalto-snr1.gtei.net>

> Writing your own read and parse routine for handling
> form action input data is infinitely superior to
> this cgi.poopmaker, which is a well documented source
> of problems and has a history of continuous upgrades
> to compensate for these endless problems.

Too true!

Joe





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

Date: Sat, 20 Jan 2001 00:12:38 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Fork stability on ActivePerl
Message-Id: <slrn96hm93.1qg.tim@degree.ath.cx>

Iain Hosking <iain_hosking@hotmail.com> wrote:
> If I do (b) is it feasible on NT to use fork() to run the processes? I'm
> running ActivePerl 5.6.0 build 623 on NT 4.0 SP5.

I've heard no evidence that fork() is stable on Win32.  I've heard
rumors, some from ActiveState reps, that it's stable.  Anyone got
evidence that ActivePerl's fork() imitation...ahem, implementation is
functional and reliable?

> The system runs round the
> clock 365 days a year so must be stable.

I was unaware that NT was capable of running 24hrs/365days. Hmm...
(Which crashed first: NT or ActivePerl? ...)

> (Down the track we may migrate the system to Linux or Solaris.)

If stability is what you need, migrating to any kind of *nix would be an
improvement.

-- 
-Tim Hammerquist <timmy@cpan.org>
The world is a tragedy to those who feel,
but a comedy to those who think.
	-- Horace Walpole


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

Date: 19 Jan 2001 19:31:50 -0500
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Jobs: Senior Software Engineer
Message-Id: <94am9m$n6p@junior.apk.net>

In article <t6685il8a73qa0@corp.supernews.com>,
Chris Stith  <mischief@velma.motion.net> wrote:
>I have seen a FAQ for this newsgroup. Perhaps we need more frequent
>postings about how to find the FAQ...

[snip]

You're new here, eh?



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

Date: Sat, 20 Jan 2001 01:44:22 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: MIME Lite Problem
Message-Id: <slrn96hrb1.2rv.efflandt@efflandt.xnet.com>

On Fri, 19 Jan 2001, Rand Simberg <simberg.interglobal@trash.org> wrote:
>On Fri, 19 Jan 2001 19:43:29 GMT, in a place far, far away,
>cfedde@fedde.littleton.co.us (Chris Fedde) made the phosphor on my
>monitor glow in such a way as to indicate that:
>
>>My guess is that you are getting "Illegal division by zero".
>>Try putting quotes around your path construct.
>
>DOH!
>
>Good guess.  It runs now, but it doesn't send the attachment...
>
>******************************************************************
>The contents of the email are:
>
>Content-Disposition: inline
>Content-Length: 57
>Content-Transfer-Encoding: binary
>Content-Type: text/plain
>
>The attached file contains your requested archive backup. 
>*******************************************************************
>
>Now how do I get it to actually do the attachment (see my code in my
>other post in this thread)?  It's just a tab-delimited database file.

Do you still have print statements in the middle of your 'attach $msg'
statement?  The ; ending the print statement ends the $msg so the rest is 
just hanging out in space.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Fri, 19 Jan 2001 23:47:25 GMT
From: jgore@home.com
Subject: Perl  - Bytecode, Compile to C, Perl2EXE 
Message-Id: <3a68d192.140770597@24.14.77.6>

Perl  - Bytecode, Compile to C, Perl2EXE 

I'm confused!
I have a perl (CGI) program which uses many other modules.
I can run it on my own server just fine.

I have two problems:
1)  I would like to distribute the program but not the source.
2)  I would like to run it on my ISP 's server (simplehost.com).

PERL2EXE:
 I could use PERL2EXE and make an executable but my ISP doesn't allow EXE's in CGI-bin.
It would keep the source secret but people could only run it on their own sever machines.

ByteCode:
I can't find a lot info about this. The module doesn't say much about how to use it.
Do most ISP's allow bytecode? Does bytecode include all the other modules my program
uses (like an EXE) ?   Any tutorial pages on this besides what comes with perl?

Compile to C:
Does this work? Any tutroial pages on it anywhere? 

I'm just looking for the best way to distribute my program and run it on a standard ISP site that
allows perl. Any help appreciated!


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

Date: 20 Jan 2001 00:49:33 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl  - Bytecode, Compile to C, Perl2EXE
Message-Id: <slrn96ho4t.rgg.abigail@tsathoggua.rlyeh.net>

jgore@home.com (jgore@home.com) wrote on MMDCXCVIII September MCMXCIII in
<URL:news:3a68d192.140770597@24.14.77.6>:
@@ Perl  - Bytecode, Compile to C, Perl2EXE 
@@ 
@@ I'm confused!
@@ I have a perl (CGI) program which uses many other modules.
@@ I can run it on my own server just fine.
@@ 
@@ I have two problems:
@@ 1)  I would like to distribute the program but not the source.

I've a solution, but just as you, I like to keep it hidden. 

@@ 2)  I would like to run it on my ISP 's server (simplehost.com).

That's not a Perl problem.

@@ PERL2EXE:
@@  I could use PERL2EXE and make an executable but my ISP doesn't allow EXE's i

Very sensible. I wouldn't allow any user to run any CGI program, so 
consider yourself lucky.

@@ It would keep the source secret but people could only run it on their own sev

You lost me here.

@@ ByteCode:
@@ I can't find a lot info about this. The module doesn't say much about how to 
@@ Do most ISP's allow bytecode? Does bytecode include all the other modules my 
@@ uses (like an EXE) ?   Any tutorial pages on this besides what comes with per

How should we know what the majority of the ISP's have for policies?

@@ 
@@ Compile to C:
@@ Does this work? Any tutroial pages on it anywhere? 

Did you try?

@@ I'm just looking for the best way to distribute my program and run it on a st
@@ allows perl. Any help appreciated!

Use the source, Luke!



Abigail
-- 
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/                xor      !@ _?
       exit print                                                  :
            print and push @_ => shift and goto &{(caller (0)) [3]}}
            split // => "KsvQtbuf fbsodpmu\ni flsI "  xor       & _


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

Date: Sat, 20 Jan 2001 00:02:00 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Perl OOP questions
Message-Id: <slrn96hll5.1qg.tim@degree.ath.cx>

nobull@mail.com <nobull@mail.com> wrote:
> > Newsgroups: comp.lang.perl,comp.lang.perl.misc
> 
> comp.lang.perl does not exist.

Does not "officially" exist.  You can, however, from many news servers,
read, post, and reply to articles in comp.lang.perl.

Interestingly
enough, some others and I have tried to tell people in comp.lang.perl
that it is, how should I say...deprecated...in favor of
comp.lang.perl.misc or one of the others.  They refuse for the most part
to leave clp because of the alleged arrogance of those who frequent
clpm.  After a couple of posts on the topic, it starts to sound a lot
like comp.lang.python instead.  Oh well.

</commentary>

-- 
-Tim Hammerquist <timmy@cpan.org>
Nearly all men can stand adversity, but if you
want to test a man's character, give him power.
	-- Abraham Lincoln


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

Date: Fri, 19 Jan 2001 23:10:55 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Perl script problem
Message-Id: <3A68CA5F.E3CB00EA@acm.org>

Ian Waters wrote:
> 
> Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
> news:slrn96g9an.2q0.bernard.el-hagin@gdndev25.lido-tech...
> > On 18 Jan 2001 08:46:23 +0000, nobull@mail.com <nobull@mail.com> wrote:
> > >"Ian Waters" <ian@ianwaters.com> writes:
> > >
> > >> Subject: Perl script problem
> > >
> > >Please write out 1000 times: "I must not post to Usenet with
> > >content-free subject lines".
> >
> > Change that to "Please write out 1000 times ON PAPER".
> > It's too easy to do it electronically. :)
> 
> Please write out a 1000 times, "I must work on my people skills and try to
> remeber that I do not own usenet."

Please write out a thousand times (on paper) "I will not post Jeopardy
style on Usenet."

John


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

Date: Sat, 20 Jan 2001 01:43:20 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl script problem
Message-Id: <slrn96hjme.8eu.tadmc@tadmc26.august.net>

jdf@pobox.com <jdf@pobox.com> wrote:
>"Ian Waters" <ian@ianwaters.com> writes:
>
>> Please write out a 1000 times, "I must work on my people skills and try to
>> remeber that I do not own usenet."


It is evident to everyone here who it is that needs the work.


>The guy helps you and guides you with humor, and you bite his hand.


Deja shows two posts from Ian here, a couple of months apart
(go see how absurd it is to try and find it in the Help Me
thread of 200 messages):

   Subject: Help Me
   Subject: Perl script problem

The answerer of the first question said:

   "A better subject line can help lots."

The answerer of the second question also mentioned the
poor Subject (two months later).

The first one hit a (negative) score rule /^help me$/i, and the 
second one just missed hitting another one /perl (problem|question)/i
(so I've updated that rule :-)

Choosing a good Subject helps you get an answer to your question.

Choosing a good Subject helps everyone else here, by making it
easier for them to find something when they go looking for it.

Choosing a bad Subject does not benefit anybody. 

Not even the OP (who we assume _wants_ an answer).


>Oops.  *plonk*
>My first kill!


I did that too. He identified himself too clearly:

   No subject (repeatedly)
   Ignores requests from regulars
   Posts in backwards time order
   New guy telling everybody else how it must be
   Deja shows 28 posts. Only two (including this one) with 
     "Re:" in Subject
   Several post with identical Subjects and Dates posted
     individually to multiple newsgroups (ie. SPAM or velveeta)


In my experience this is a record for most violations of 
netiquette piled up at once.

Straight to the 3rd level for spammers like you Ian.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 19 Jan 2001 16:28:27 -0700
From: Rob Greenbank <rob@frii.com>
Subject: Re: Random Numbers with a Twist
Message-Id: <mkfh6tg39vcci60cdles5aq7prfngv7hh9@4ax.com>

On 16 Jan 2001 23:49:38 GMT, abigail@foad.org (Abigail) wrote:

>John Boy Walton (johngros.NOSPAM@bigpond.net.au) wrote on MMDCXCV
>September MCMXCIII in <URL:news:bP396.65731$xW4.515596@news-server.bigpond.net.au>:
>\\ 
>\\ "Garry Williams" <garry@zvolve.com> wrote in message
>\\ news:fH296.49$h41.2755@eagle.america.net...
>\\ > On Tue, 16 Jan 2001 11:56:01 -0700, Rob Greenbank <rob@frii.com>
>\\ > wrote:
>\\ >
>\\ > But Abigail already pointed out that this method could lead to no
>\\ > solution by unfortunate choices early in the interation you propose.
>\\ >
>\\ > --
>\\ > Garry Williams
>\\ He did point out an easy test for it (the empty hash) and then you could run
>\\ through again.
>
>
>*shudder*
I *totally* agree!

>
>That would lead to an extremely slow program. It's not hard to come with
>an example where you have more than 90% of picking the first point "wrong",
>but you can pick over half of the required points before your hash empties.

Agreed!  This is more due to the nature of the problem, however.  If
the points generated are truly random selections, and the size of the
grid (I don't know anything better to call it) is not large enough,
then your first *few* selections may, in fact, suddenly make the
problem unsolvable.  

>
>The amount of backtracks required before picking a right point are
>overwelming.
>
I see only two ways to avoid the possibility of either multiple
attempts or backtracking -- either the size of the "grid" is large
enough to insure it won't happen, or you limit the randomness.  I
probably wouldn't backtrack anyway -- I'd probably just fail it and
let the person running the program decide when they've had enough.   

Interesting thought -- if you run out of available points very near
the end of the process, the probability of the solution being easily
computed is likely higher than if you run out of points half or 3/4 of
the way through.  

Not really a perl problem, I guess, more of an algorithmic problem
(I'm sure there's a better newsgroup, somewhere).  It's a fun one to
ponder, though -- I'm just glad my job doesn't depend on solving this
problem on this particular Friday afternoon.     :-)

>
>Abigail

Have a great day,

	Rob


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

Date: 20 Jan 2001 00:42:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Random Numbers with a Twist
Message-Id: <slrn96hno0.rgg.abigail@tsathoggua.rlyeh.net>

Rob Greenbank (rob@frii.com) wrote on MMDCXCVIII September MCMXCIII in
<URL:news:mkfh6tg39vcci60cdles5aq7prfngv7hh9@4ax.com>:
~~ 
~~ I see only two ways to avoid the possibility of either multiple
~~ attempts or backtracking -- either the size of the "grid" is large
~~ enough to insure it won't happen, or you limit the randomness.  I
~~ probably wouldn't backtrack anyway -- I'd probably just fail it and
~~ let the person running the program decide when they've had enough.   

Here's an algorithm that will work, and doesn't backtrack (it will
never get "stuck"):

    Let G be the grid on which the n points have to be placed.
    Let d be the minimum required distance.

    First determine whether there is a solution. If not, report this
    and exit unsuccessfully.

    Else:
	Place the points (P_1 .. P_n) on G in a valid way (for instance
	by evenly distributing them).
	
	repeat
	    Pick j randomly 1 <= j <= n. 
	    Remove P_j from G.
	    Let S be the set of points of G such that the distance of
	    each point of S to P_k (1 <= k <= n && k != j) is at least d.
	    (Note that S cannot be empty, the previous position of P_j
	     must be an element of S).
	    Randomly select an element s of S, and place P_j on s.
	until an_appropriate_time

Invariant:
    A h, i: 1 <= h < i <= n: dist (P_h, P_i) >= d /\ P_h on G /\ P_i on G.

The hard part is deciding when to stop, that is, when is the set
random enough?


Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54"; s/<<EOT/<<EOT/e; print;
Just another Perl Hacker
EOT


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

Date: Sat, 20 Jan 2001 00:02:45 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Suppressing stderr on `` commands
Message-Id: <ant200045f7ffNdQ@oakseed.demon.co.uk>

In article <slrn96hheu.rgg.abigail@tsathoggua.rlyeh.net>, Abigail
<URL:mailto:abigail@foad.org> wrote:
> 
> If there's no perldoc on your system,
> you have a broken installation of perl.

We've covered this several time before so I'll be brief: The port of
Perl (or should that be perl) for RISC OS does not come with a perldoc
utility. RISC OS like most non-UNIX systems does not have a man
utility. RISC OS has several good web browsers so HTML is a sensible
way to keep the Perl docs. The same is true of the other platform that
I use Perl on, EPOC.

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Sat, 20 Jan 2001 01:09:30 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Suppressing stderr on `` commands
Message-Id: <Pine.LNX.4.30.0101200108270.18020-100000@lxplus003.cern.ch>

On Sat, 20 Jan 2001, James Taylor wrote:

> way to keep the Perl docs. The same is true of the other platform that
> I use Perl on, EPOC.

I installed the Perl docs on my old Psion 5, even though there wasn't
enough memory to install the Perl software.  What are you whining
about?

-- 

        You're on your own, kid.  You've ripped the safety tag from
        the mattress, so the warranty is void.  -- Randal Schwartz




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

Date: Sat, 20 Jan 2001 01:43:17 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Suppressing stderr on `` commands
Message-Id: <slrn96hdvs.8eu.tadmc@tadmc26.august.net>

James Taylor <james@NOSPAM.demon.co.uk> wrote:

>but there is no perldoc on my system 


Why not?

It is part of a normal install.

I do not know of any platforms where perl is available and
perldoc is not available (since perldoc is written in perl).

If perl is broken on some platform, I'd like to know about it
even if I don't use that platform. Please share it with us,
maybe somebody will even fix it for that platform.


If "my system" is "my ISP", then get perl for your home
computer. It is free and comes with the docs.


Folks without easy access to Perl's standard docs get entries
in config files, don't let that happen to you.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 20 Jan 2001 00:09:28 GMT
From: "cam" <cam@home.com>
Subject: url parsing
Message-Id: <YG4a6.38750$ED.1454033@news1.rdc1.bc.home.com>

Hi:

Can someone tell me how I can perform some simple parsing of HTML?

For example, if the code on a url is two lines reading:

<B>Hello <i>Bob</i>I hope you have a </b> nice day<BR>
<p>Talk to you <a href=thanks.htm>later</a>


What would the syntax be to:
* delete the contents between the <i> and </i>
* delete everything after the </b> in the first line
* change the url in the second line to be <a href=bob.htm> in the second
line.

In other words, I need to know the syntax required to filter HTML data using
Perl.
I've been trying to find online resources by they seem to be too elementary
or too advanced.

Thanks!!!

Cam











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

Date: Fri, 19 Jan 2001 17:37:15 -0800
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: url parsing
Message-Id: <3a68ebc7$1@news.microsoft.com>

"cam" <cam@home.com> wrote in message
news:YG4a6.38750$ED.1454033@news1.rdc1.bc.home.com...
> Can someone tell me how I can perform some simple parsing of HTML?

HTML or URL? Somehow the subject line and the body of your posting disagree

> For example, if the code on a url is two lines reading:
> <B>Hello <i>Bob</i>I hope you have a </b> nice day<BR>
> <p>Talk to you <a href=thanks.htm>later</a>
>
> What would the syntax be to:
> * delete the contents between the <i> and </i>

s/<i>.*<\/i>/<i><\/i>/;

> * delete everything after the </b> in the first line

s/<\/b>.*/<\/b>/

> * change the url in the second line to be <a href=bob.htm> in the second
> line.

s/thanks\.htm/bob.htm/

This will do what you asked for. However, somehow I have the feeling this is
not what you actually want.

> In other words, I need to know the syntax required to filter HTML data
using
> Perl.
> I've been trying to find online resources by they seem to be too
elementary
> or too advanced.

You cannot use REs to parse HTML, use HTML::Parser instead.

jue




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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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