[19215] in Perl-Users-Digest
Perl-Users Digest, Issue: 1410 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 30 18:10:42 2001
Date: Mon, 30 Jul 2001 15:10: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: <996531014-v10-i1410@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 30 Jul 2001 Volume: 10 Number: 1410
Today's topics:
Module help needed! <a@b.c>
Multi document interface <Pcmann1@btinternet.com>
Re: negative lookahead <ilya@martynov.org>
Re: newbe question splitting a string into two differen slash@dot.c.o.m.org
Re: newbe question splitting a string into two differen <Tassilo.Parseval@post.rwth-aachen.de>
Re: newbe question splitting a string into two differen (Tad McClellan)
Re: newbe question splitting a string into two differen <mbudash@sonic.net>
Re: PERL compiler...... <AHALL5@nc.rr.com>
Perl help file? <cditty@hotmail.com>
Re: Perl help file? <thomas@baetzler.de>
Re: Recommendation for a book covering MySQL and Perl (Rodney Broom)
Returning values to a shell script <Julie_Warden.spamfree@hotmail.com>
Re: Returning values to a shell script <Tassilo.Parseval@post.rwth-aachen.de>
Re: Returning values to a shell script <Tassilo.Parseval@post.rwth-aachen.de>
Re: Returning values to a shell script <bernie@fantasyfarm.com>
Re: Self-Searchable Perl documention - Extremely Useful <newspost@coppit.org>
Re: Starting a deamon from another deamon <ilya@martynov.org>
Telnet/MUD server <philip@zaynar.demon.co.uk>
two questions <scorwin@radford.edu>
Re: two questions <iltzu@sci.invalid>
Re: where is poetry.ps? <jpixton@dircon.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 30 Jul 2001 15:00:19 -0700
From: BCC <a@b.c>
Subject: Module help needed!
Message-Id: <3B65D8F3.E295DA8C@b.c>
Hi, I am clearly screwing something up here, but I cannot figure it
out. I built a module with some small test subroutines, that I wish to
access via the object oriented method ($mod->sub()).
I have a test cgi called index.cgi that calls the module, builds an
object (thanks for the help on getting this part done! :), and so on.
I believe the problem may be with the call to readCookie from loggedIn
because loggedIn is not doing the call through an object reference...?
But Im not sure. readCookie will need to be called from within the
module, and through and object. When I execute index.cgi via my
browser, I get this error:
[Mon Jul 30 14:51:42 2001] index.cgi: Function CGI::Object::unescape
does not exist at /usr/lib/perl5/5.6.1/CGI.pm line 112
[Mon Jul 30 14:51:42 2001] Carp.pm: Attempt to free unreferenced scalar
at /usr/lib/perl5/5.6.1/Carp.pm line 119.
Eh? What am I doing wrong?
Thanks!
Bryan
Here are the files:
index.cgi
---------
#!/usr/bin/perl -w
use CgiMOD; ## My hand-rolled module
use CGI qw(:standard);
use CGI::Carp 'fatalsToBrowser';
my $cmod = new CgiMOD("index.cgi");
print header();
my $logged = $cmod->loggedIn();
print $logged;
CgiMOD.pm
---------
package CgiMOD;
use 5.006;
use strict;
use warnings;
use Global; ## This has a bunch of global vars
use CGI qw(:standard);
use CGI::Carp 'fatalsToBrowser';
use CGI::Cookie;
$CGI::POST_MAX=1024 * 5000; # Set 5M limit on uploads
use DBI;
use Data::Table;
our $VERSION = '0.01';
sub new { ## I amended this code from advice I received from the ng
yesterday
my $class = shift;
my $self = {}; # create a reference
bless $self, $class; # make it part of this class
$self->{string} = shift; # initialize it w/ the argument
return $self;
}
## Custom subs
sub readCookie {
my $shift = shift;
my %cookies = fetch CGI::Cookie;
my $login = $cookies{'Oreo'}{value}[0];
my $level = $cookies{'Oreo'}{value}[1];
if ($login && $level) {
return ($login, $level);
} else {
return ("", "");
}
}
sub loggedIn {
my ($shift, $login, $level) = readCookie();
if (($login ne "null" && $level ne "null") && ($login ne "" && $level
ne "")) {
return 1;
} else {
return 0;
}
}
------------------------------
Date: Mon, 30 Jul 2001 21:58:38 +0100
From: "Peter Mann" <Pcmann1@btinternet.com>
Subject: Multi document interface
Message-Id: <9k4hou$6su$1@neptunium.btinternet.com>
Does anyone know if it is possible to create a multi-document interface
within the Perl/Tk kit!
I cant find any widget that provides for a MDI!
Does anyone know otherwise?
Thanks in advance,
Regards, - Pete
------------------------------
Date: 30 Jul 2001 23:07:13 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: negative lookahead
Message-Id: <871ymygrry.fsf@abra.ru>
BL> mike wrote:
>> I want to match a string that starts with "aaa" and ends with "bbb" as
>> long as the is no "zzz" between aaa and bbb.
>>
>> My attempt:
>>
>> $mystring =~ m/aaa.*?(?!zzz)bbb/si;
>>
>> Result:
>>
>> Still matches even if the string contains zzz.
BL> I think this will work:
BL> m/aaa(?:(?!zzz).)*?bbb/si;
BL> but it probably won't be the fastest scheme imaginable.
Correct pattern is
m/^aaa(?:(?<!zzz).)*bbb$/si;
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Mon, 30 Jul 2001 18:33:15 GMT
From: slash@dot.c.o.m.org
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <3b65a7e3.2063203@news.freeserve.co.uk>
On Mon, 30 Jul 2001 10:37:16 -0700, "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
>fred58 wrote:
>
>> Right here is my problem i would like to split this string at the |
>> "hello | good buy" into two different variables but im unsure of the
>> best way to do this any help would be gratefully received
>
>You have failed to...
[...the usual garbage - I don't even bother reading it anymore...]
Anyone else get the impression G is just a rather simple 'bot, spewing out the same
rote insults and cut'n'paste 1st grader scripts over and over again?
------------------------------
Date: Mon, 30 Jul 2001 20:29:59 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <3B65A7A7.2000803@post.rwth-aachen.de>
slash@dot.c.o.m.org wrote:
>On Mon, 30 Jul 2001 10:37:16 -0700, "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
>
>>fred58 wrote:
>>
>>>Right here is my problem i would like to split this string at the |
>>>"hello | good buy" into two different variables but im unsure of the
>>>best way to do this any help would be gratefully received
>>>
>>You have failed to...
>>
>
>[...the usual garbage - I don't even bother reading it anymore...]
>
>Anyone else get the impression G is just a rather simple 'bot, spewing out the same
>rote insults and cut'n'paste 1st grader scripts over and over again?
>
No, at least not a simple bot. ;-) There sometimes is a vague reference
to the original posting.
Yet I have two theories in mind:
1) This object is just someone taking pleasure in deliberately insulting
people and happily following the flameware.
2) Godzilla! has been sent over from the Python-people to compell new
users by compromising the newsgroup so that newbies will eventually
think Perl-people are rude and use Python instead. ;-)
Tassilo
--
The good (I am convinced, for one)
Is but the bad one leaves undone.
Once your reputation's done
You can live a life of fun.
-- Wilhelm Busch
------------------------------
Date: Mon, 30 Jul 2001 14:09:50 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <slrn9mb8ne.dsp.tadmc@tadmc26.august.net>
Michael Budash <mbudash@sonic.net> wrote:
>In article <9k46ge$q9e$1@news01.cit.cornell.edu>, "Oliver"
><ow22@nospam-cornell.edu> wrote:
>
>> "fred58" <none@nowere.com> wrote in message
>> news:3roamt4jqf75g3ierd9qic6d8m8ar42dvj@4ax.com...
>>
>> how could i split a string like
>>
>> hello good bye 1 444
>>
>> into an array of strings (hello,good,bye,1,444).
>perldoc -f split
Indeed.
>$string = 'hello good bye 1 444';
>@array_of_strings = split(/\s+/, $string);
Note that with Perl's defaults, it gets even easier:
$_ = 'hello good bye 1 444';
my @array_of_strings = split; # Do What I Mean
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 30 Jul 2001 19:27:39 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <mbudash-AFD103.12274530072001@news.sonic.net>
In article <slrn9mb8ne.dsp.tadmc@tadmc26.august.net>,
tadmc@augustmail.com wrote:
> Michael Budash <mbudash@sonic.net> wrote:
> >In article <9k46ge$q9e$1@news01.cit.cornell.edu>, "Oliver"
> ><ow22@nospam-cornell.edu> wrote:
> >
> >> "fred58" <none@nowere.com> wrote in message
> >> news:3roamt4jqf75g3ierd9qic6d8m8ar42dvj@4ax.com...
> >>
> >> how could i split a string like
> >>
> >> hello good bye 1 444
> >>
> >> into an array of strings (hello,good,bye,1,444).
>
> >perldoc -f split
>
>
> Indeed.
>
>
> >$string = 'hello good bye 1 444';
> >@array_of_strings = split(/\s+/, $string);
>
>
> Note that with Perl's defaults, it gets even easier:
>
> $_ = 'hello good bye 1 444';
> my @array_of_strings = split; # Do What I Mean
absolutely. thanks for the addition.
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Mon, 30 Jul 2001 19:45:00 GMT
From: "Antoine Hall" <AHALL5@nc.rr.com>
Subject: Re: PERL compiler......
Message-Id: <0Pi97.54844$TM5.5942324@typhoon.southeast.rr.com>
Doesn't the Perl2exe program create LARGE executable files?
"Peter Mann" <Pcmann1@btinternet.com> wrote in message
news:9k3e1r$j8o$1@neptunium.btinternet.com...
> Hi there!
> goto: http://www.suite101.com/article.cfm/7977/53268 and read this
article!
> For the software visit, www.indigostar.com and the software that might
help
> you is called Perl2EXE
>
> Regards,
> Peter C. Mann
>
>
>
> "Kolorove Nebo" <sky@mail.lviv.ua> wrote in message
> news:3B6501CE.8C421EDA@mail.lviv.ua...
> > Is there any PERL compiler to build exe files from perl files on win32
> > platforms?
> >
> > Thanks...
>
>
------------------------------
Date: Mon, 30 Jul 2001 21:24:48 GMT
From: "Chris" <cditty@hotmail.com>
Subject: Perl help file?
Message-Id: <Agk97.11024$5w4.1037300@typhoon.midsouth.rr.com>
Does anyone know where I can download a .chm file for perl? Does one exist?
Looking for something that has all the functions in it.
Thanks
------------------------------
Date: Mon, 30 Jul 2001 23:50:00 +0200
From: Thomas Bätzler <thomas@baetzler.de>
Subject: Re: Perl help file?
Message-Id: <mhlbmt40ul0p7e6va7861v4qq1fqqlthg2@4ax.com>
On Mon, 30 Jul 2001 21:24:48 GMT, "Chris" <cditty@hotmail.com> wrote:
>Does anyone know where I can download a .chm file for perl? Does one exist?
>Looking for something that has all the functions in it.
I assume you're running on Win32. Get the ActiveState Perl port,
install it, and check out the HTML subdirectory.
HTH,
------------------------------
Date: Mon, 30 Jul 2001 22:13:59 GMT
From: NOrbroomS@PaMdesert.net (Rodney Broom)
Subject: Re: Recommendation for a book covering MySQL and Perl
Message-Id: <9k4ldd$ria$1@nnrp1.phx.gblx.net>
You could buy a book for this, but I'm not sure there's a need. As for using
MySQL: You'll need to know SQL for most things. But that's true of any SQL
based RDBMS. For the administration side, you don't need Perl at all and
knowing Perl won't help you. The single fastest (and probably most accurate)
source of documentation is the mysql.com web site.
As for using Perl with MySQL: It's pretty much like using Perl with any other
RDBMS that has a driver for DBI. "DBI" is the DataBase Interface for Perl. Try
these links:
- DBI:
* Information
http://search.cpan.org/doc/TIMB/DBI-1.19/DBI.pm
* Download
http://www.cpan.org/authors/id/TIMB/DBI-1.19.tar.gz
- MySQL
* Information
- Perl
http://search.cpan.org/doc/JWIED/DBD-mysql-2.0902/lib/Mysql.pm
- Database
http://www.mysql.com/documentation/index.html
* Download
- Perl
http://www.cpan.org/authors/id/JWIED/DBD-mysql-2.0902.tar.gz
- Database
http://www.mysql.com/downloads/index.html
---
Rodney
Programmer: Desert.Net
------------------------------
Date: Mon, 30 Jul 2001 15:26:40 -0400
From: Julie Warden <Julie_Warden.spamfree@hotmail.com>
Subject: Returning values to a shell script
Message-Id: <trcbmtc8u2dec16h1np1s3le57f3fpvcjd@4ax.com>
Group,
I have written a Perl script to check the age of a filename, accepting
MMM DD YYYY, and returning the age in minutes. To communicate with
the bourne shell script, I ended up using the "value of" option with
BOURNE_VARIABLE=`my_perl_script.pl MMMM DD YYYY`, with the Perl script
doing a print of the value to return.
I looked through much of the online documentation, but found nothing
about returning values to a shell script. Does anyone have any
alternatives to what I'm doing.
By the way, I've got 3 days of Perl under my belt, with a manual on
order...
Thanks,
Julie
------------------------------
Date: Mon, 30 Jul 2001 22:20:04 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Returning values to a shell script
Message-Id: <3B65C174.2010506@post.rwth-aachen.de>
Julie Warden wrote:
>Group,
>
>I have written a Perl script to check the age of a filename, accepting
>MMM DD YYYY, and returning the age in minutes. To communicate with
>the bourne shell script, I ended up using the "value of" option with
>BOURNE_VARIABLE=`my_perl_script.pl MMMM DD YYYY`, with the Perl script
>doing a print of the value to return.
>
>I looked through much of the online documentation, but found nothing
>about returning values to a shell script. Does anyone have any
>alternatives to what I'm doing.
>
I am not 100% sure that I understood what you mean. If you want to pass
the stdout of your script to some other UNIX-command, you could use
backticks, like in
rm `locate *.tmp'
which is equal to
rm $(locate *.tmp)
This would save you the use of a shell-variable.
Greetings,
Tassilo
--
The fashionable drawing rooms of London have always been happy to accept
outsiders -- if only on their own, albeit undemanding terms. That is to
say, artists, so long as they are not too talented, men of humble birth,
so long as they have since amassed several million pounds, and socialists
so long as they are Tories.
-- Christopher Booker
------------------------------
Date: Mon, 30 Jul 2001 22:25:25 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Returning values to a shell script
Message-Id: <3B65C2B5.4000005@post.rwth-aachen.de>
Tassilo von Parseval wrote:
> Julie Warden wrote:
>
>> Group,
>>
>> I have written a Perl script to check the age of a filename, accepting
>> MMM DD YYYY, and returning the age in minutes. To communicate with
>> the bourne shell script, I ended up using the "value of" option with
>> BOURNE_VARIABLE=`my_perl_script.pl MMMM DD YYYY`, with the Perl script
>> doing a print of the value to return.
>>
>> I looked through much of the online documentation, but found nothing
>> about returning values to a shell script. Does anyone have any
>> alternatives to what I'm doing.
>>
>
> I am not 100% sure that I understood what you mean. If you want to
> pass the stdout of your script to some other UNIX-command, you could
> use backticks, like in
>
> rm `locate *.tmp'
shit, no. These are supposed to be two backticks: rm `locate *.tmp`
--
I might have gone to West Point, but I was too proud to speak to a congressman.
-- Will Rogers
------------------------------
Date: Mon, 30 Jul 2001 17:18:39 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: Returning values to a shell script
Message-Id: <dmjbmt0i5tfojt1advhpelqtomsoaaa2l8@news.supernews.net>
Julie Warden <Julie_Warden.spamfree@hotmail.com> wrote:
} I have written a Perl script to check the age of a filename, accepting
} MMM DD YYYY, and returning the age in minutes. To communicate with
} the bourne shell script, I ended up using the "value of" option with
} BOURNE_VARIABLE=`my_perl_script.pl MMMM DD YYYY`, with the Perl script
} doing a print of the value to return.
}
} I looked through much of the online documentation, but found nothing
} about returning values to a shell script. Does anyone have any
} alternatives to what I'm doing.
I don't think so. The bourne shell is a *strictly* text world. so there's
not really any other way to pass 'values' back other than to write them to
your STDOUT and have the shell capture them. Absolutely SOP, same thing we
do in awk scripts, other shell scripts, internal shell functions.
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Mon, 30 Jul 2001 15:01:24 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Self-Searchable Perl documention - Extremely Useful!
Message-Id: <3B65AF04.2050906@coppit.org>
John Holdsworth wrote:
> If you have ActiveState's "Active Perl" installed on a PC along
> with Perl Documentation you can make it searchable without having
> to run a Web server or be connected to the internet by running
> this script:
>
> http://www.openpsp.org/source/perltoc.pl
>
> This pathes the the ActiveState table of contents to use "PerlScript"
> and run as a Web server inside Internet Explorer (port 8088).
Hi John,
I tried it out, and it's really cool. Could you tell us a little bit
about how it works? In particular:
- Where is the web server? Does IE have a server built-in and listening
on port 8088?
- How are you running Perl? I see that you mentioned PerlScript in
another post...
- What about cross-platform, cross-browser compatibility? Do you just
need a browser with PerlScript? Any other requirements?
The main reason I ask is that I'm interested in techniques for building
web-based interfaces to Perl programs, and most Windows folks don't have
web servers running on their machines.
Thanks!
David
------------------------------
Date: 30 Jul 2001 22:28:15 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Starting a deamon from another deamon
Message-Id: <877kwqgtkw.fsf@abra.ru>
GT> You need daemonize (not sure which faq it is in; try searching
GT> perldoc.com).
It is in 'perldoc perlipc'
GT> use POSIX 'setsid';
GT> sub daemonize {
GT> chdir '/' or die "Can't chdir to /: $!";
GT> open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
GT> open STDOUT, '>/dev/null'
GT> or die "Can't write to /dev/null: $!";
GT> defined(my $pid = fork) or die "Can't fork: $!";
GT> exit if $pid;
GT> setsid or die "Can't start a new session: $!";
GT> open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
GT> }
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Mon, 30 Jul 2001 22:35:29 +0100
From: Philip Taylor <philip@zaynar.demon.co.uk>
Subject: Telnet/MUD server
Message-Id: <+PFhZBAhMdZ7EwLc@zaynar.demon.co.uk>
I'm making a text-based FPS-style Internet game (well, actually it's
an SPS, but that's not important), which functions in a fairly similar
way to a MUD. The server runs a Perl program, and users can connect to
it using whatever Telnet client they want.
Firstly, is there a module which can be used for this? I've looked at
Net::Telnet but from its readme file, "Net::Telnet allows you to make
client connections to a TCP port" -- I need the server rather than the
client.
Currently I'm using a modified version of an example I found somewhere
on the internet (although I've forgotten where), which uses the Socket
routines.
"Programming Perl" mentions using 'fork' to allow multiple users, but
this opens a lot of processes, which is presumably not good if there are
lots of simultaneous users. The system which I'm using does it all
inside the main loop -- it waits until one of the users has some data
(with 'vec'), then receives it (with 'sysread'), then repeats.
However, I'm not sure exactly how this works. Is all the data passed
to the server before vec detects anything, then sysread copies the data
immediately from memory?
Or does vec merely know that the user has some data waiting, then
sysread has to wait a few fractions of a second while downloading the
information? I need to avoid anything in which one user could freeze the
server for every other user...
The main server-related sections of the code are shown below (there
might be a few minor bits which I accidentally removed while cutting out
the unnecessary code, but it shows the main sections of how it ought to
work):
use Socket;
# Set up main server socket (S)
$port = 1979;
$proto = getprotobyname('tcp');
socket(S,AF_INET,SOCK_STREAM,$proto) or die "socket: $!";
bind(S, pack('S n a4 x8', AF_INET, $port, "\0\0\0\0")) or die "bind:$!";
listen(S, 10) or die "listen: $!";
while (1) { # this loop repeats after each byte of input
# Set the list of sockets to be read from
$rin = '';
# The filehandle S refers to the main 'server' socket
vec($rin, fileno(S), 1) = 1;
# @sockets is a list of the socket numbers.
# $socket[1]=1, $socket[5]=5, etc, EXCEPT when the user has
# left -- in that case, $socket[_]=0
foreach $socket (@sockets) {
next if ($socket == 0); # don't look at closed sockets
# Each socket needs a unique filehandle, but these can't be just
# numbers, so they're 'NS' followed by the socket number
vec($rin, fileno('NS'.$socket), 1) = 1;
}
# wait for one of the inputs to be ready
select($rout=$rin, undef, undef, undef);
if (vec($rout, fileno(S), 1)) {
# A new user has connected, so set up the socket
++$con;
$sockets[$con] = $con;
$addr = accept('NS'.$sockets[$con], S) or die $!;
} else {
# Get input from each user who's got some data
foreach $socket (@sockets) {
next if $socket == 0;
if (vec($rout, fileno('NS'.$socket), 1)) {
&readInput($socket);
}
}
}
}
sub readInput {
# Reads a byte of input from the user specified by the parameter
my $socket = 'NS'.$_[0];
if ((sysread($socket, $c, 1) <= 0) or ($c eq "\n")) {
# end of input -- process commands
} else {
# add character to input buffer
}
}
I've had it running with about 4 users, and it seemed to work
successfully (although there were some major bugs which I didn't notice,
such as the server freezing between when a Microsoft Telnet user started
and finished typing, so I might have missed some smaller ones too), but
I want something that's I know will be reliable with lots of users.
I can always try things and see if they work (in fact, I'll probably
make some computer-controlled AI bots to play against when there aren't
many human players, and could just add a load of them in order to test
the system), but I'd like to know if anyone has past experience with
things like this.
Any assistance will be greatly appreciated!
--
Philip Taylor
philip @ zaynar . demon . co . uk
http://robowarriors.ultrastore.com/legoworld.shtml
-- If the Earth was made of Lego...
------------------------------
Date: Mon, 30 Jul 2001 14:05:47 -0400
From: Stephen Corwin <scorwin@radford.edu>
Subject: two questions
Message-Id: <3B65A1FB.7F6973F1@radford.edu>
Salaam, Gurus!
My first question is for someone who understands Perl garbage collection
much better than I do. What's the quickest way to destroy a tree in
which each node is a Perl object? I'd like to simply destroy all
references to the root, but I'm not sure exactly what that will
accomplish. The books I have don't explain gc in detail; they just say
that items are deleted when all references to them have been deleted.
Depending on how this is done, if I just delete all references to the
root, gc may take as many passes as there are plies in the tree to
delete all nodes. Would I be better off traversing the tree and
destroying references from the leaves up?
A second question is about just how much overhead objects take. On a
machine with 128Mb RAM (and nothing else running except for Win98) I
built a tree with 80,000 nodes. Each node held about 250 bytes of data,
for about 20Mb total. There are instance methods, but those shouldn't
add much to the total. Yet stuff was swapped out to disk; I could hear
the disk being hit repeatedly, and everything was very slow. What does
it actually cost to use objects? And is there anything to be done?
Must I implement the tree using arrays?
Thanks in advance,
Steve
------------------------------
Date: 30 Jul 2001 20:22:07 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: two questions
Message-Id: <996522262.27690@itz.pp.sci.fi>
In article <3B65A1FB.7F6973F1@radford.edu>, Stephen Corwin wrote:
>
>My first question is for someone who understands Perl garbage collection
>much better than I do. What's the quickest way to destroy a tree in
>which each node is a Perl object? I'd like to simply destroy all
>references to the root, but I'm not sure exactly what that will
>accomplish. The books I have don't explain gc in detail; they just say
>that items are deleted when all references to them have been deleted.
Garbage collection in current perls is based on simple reference
counting. (This is supposed to change in Perl 6.) When the reference
count of a variable goes to 0, it gets deleted. This may cause the
reference counts of other variables to reach 0, etc.. That simple.
Yes, this means that circular reference chains will linger in memory
forever, unless they are explicitly broken by the programmer.
>Depending on how this is done, if I just delete all references to the
>root, gc may take as many passes as there are plies in the tree to
>delete all nodes. Would I be better off traversing the tree and
>destroying references from the leaves up?
If the nodes of the tree contain references to their parents, or to the
whole tree, or to anything that might possibly indirectly refer back to
the node itself, then you'll need to delete all the nodes yourself.
If the tree is a simple nested data structure, with no reference loops,
then perl's garbage collector will handle it.
If you're not sure, and can't afford to ignore memory leaks, then it's
better to be safe than sorry and do it yourself anyway.
>A second question is about just how much overhead objects take. On a
Lots. Or rather, all perl variables take a lot of overhead -- blessing
a variable to make it an object only adds a little bit to that.
>machine with 128Mb RAM (and nothing else running except for Win98) I
>built a tree with 80,000 nodes. Each node held about 250 bytes of data,
>for about 20Mb total. There are instance methods, but those shouldn't
>add much to the total. Yet stuff was swapped out to disk; I could hear
There's a famous rule of thumb: Estimate a reasonable memory usage and
multiply by ten. In your case, that quick and dirty estimate yields
200Mb, which would indeed induce swapping.
>the disk being hit repeatedly, and everything was very slow. What does
>it actually cost to use objects? And is there anything to be done?
>Must I implement the tree using arrays?
You could always get the Inline module and implement your tree in C. Or
try searching the CPAN for a module that fills your needs. (I just did,
and couldn't find any, but you know better than I do what you want.)
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Mon, 30 Jul 2001 21:38:53 +0100
From: jbp <jpixton@dircon.co.uk>
Subject: Re: where is poetry.ps?
Message-Id: <3ehbmt0ro15m2bbsn1tec8b6hkit2a1bag@4ax.com>
At Mon, 30 Jul 2001 17:07:01 +0900, miyahara makoto said:
>hi
>
>now I'm searching for sharon's report about perl poem
>"poetry.ps"."Programming Perl" wrote it's on
>www.perl.com/CPAN/misc/poetry.ps but I can't
>find any copies there.
Try here:
http://learn.acdtrux.ath.cx/randomfiles/plpaper.ps
--
Joseph Birr-Pixton .:|:. http://ifihada.com .:|:. ICQ#40675236
<pre><?php $s="sevaw:enis:";for($i=0;$i<=1920;$i++){$c=$i%96;$x=10-$c
%11;$r=floor($i/96);if($i==($r*96))echo"\n";if(10+floor(10*-sin($c/10
))==$r){echo"*";}else{if($r==10){echo$s[$x];}else{echo" ";}}}?></pre>
------------------------------
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 1410
***************************************