[10756] in Perl-Users-Digest
Perl-Users Digest, Issue: 4355 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 3 21:17:28 1998
Date: Thu, 3 Dec 98 18:00:23 -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 Thu, 3 Dec 1998 Volume: 8 Number: 4355
Today's topics:
Re: a (naive?) complaint about the Pod:: modules (Martien Verbruggen)
Re: Can standard Perl functions be overloaded ? (Mark-Jason Dominus)
Re: Can standard Perl functions be overloaded ? (Martien Verbruggen)
Checkboxes <anty_84@yahoo.com>
Re: Checkboxes (Martien Verbruggen)
Fast way to produce block of random bytes? Gerben_Wierda@RnA.nl
Is this the best possible RegEx? <gcleaves@bigfoot.com>
Re: Is this the best possible RegEx? (Martien Verbruggen)
Re: Is this the best possible RegEx? Lee.Lindley@bigfoot.com
Re: Memory in Perl <tripp.lilley@perspex.com>
More information defining PODs needed. (Hawkwynd)
Re: More information defining PODs needed. (Martien Verbruggen)
Re: Need Perl programming -- please advise... (brian d foy)
Re: Open or Create a file (Martien Verbruggen)
Question: Ms IIS WWW server releasing resources used by <DFULTON@prodigy.net>
Re: Question: Ms IIS WWW server releasing resources use (Erik)
Re: Question: Ms IIS WWW server releasing resources use (Martien Verbruggen)
Re: Random integer numbers (1,2,3,4,5....,.....) HOW??? (brian d foy)
Re: Reading a text file & putting into variables <john_z@hotmail.com>
Re: Regex question (Martien Verbruggen)
Re: signals on Windows nt (Martien Verbruggen)
Re: system call (Martien Verbruggen)
Re: Tool to reverse engineer perl code (brian d foy)
Using formats in Perl <tweiler@ford.com>
Re: Using formats in Perl (Martien Verbruggen)
Re: Using RCS in Perl scripts <tripp.lilley@perspex.com>
Re: variable inside variable (Charles DeRykus)
Win32::API: maximize window vertically? <kin@symmetrycomm.com>
Re: wwwboard crash prevention (i hope) (brian d foy)
Re: wwwboard question - file locking (brian d foy)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 03 Dec 1998 23:48:39 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: a (naive?) complaint about the Pod:: modules
Message-Id: <rrF92.22$MF3.212@nsw.nnrp.telstra.net>
In article <7472oi$l6n$1@nonews.col.hp.com>,
"Tim Chambers" <tbc@col.hp.com> writes:
> I wrote the enclosed snippet to report on the lines in each POD paragraph.
Maybe you want the Pod::Parser module, and its associates. I am not
certain that they will do everything you need, but the name seems
pretty suggestive that they may.
http://www.perl.com/CPAN/authors/id/BRADAPP
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd. | excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: 3 Dec 1998 20:28:00 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Can standard Perl functions be overloaded ?
Message-Id: <747dr0$4ju$1@monet.op.net>
In article <74681r$v1m$1@nnrp1.dejanews.com>,
<vander_graph@hotmail.com> wrote:
>1. Can either A or M redefine the (say) the open() function,
>so that when B calls open(), it is another open() in A or M
>that is called ?
It depends on the function. But no, you can't redefine `open'.
>2. If yes, can A call the _real_ open(), after possibly doing
>some checks ?
>3. If yes, can B _somehow_ _still_ call the real open()?
If you redefine (for example) `localtime', you can still
get the original function with CORE::localtime.
>4. And if yes, can A or M do something so that B can never call
>the real open() ?
No.
------------------------------
Date: Fri, 04 Dec 1998 01:55:25 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Can standard Perl functions be overloaded ?
Message-Id: <hiH92.61$MF3.251@nsw.nnrp.telstra.net>
In article <74681r$v1m$1@nnrp1.dejanews.com>,
vander_graph@hotmail.com writes:
> 1. Can either A or M redefine the (say) the open() function,
> so that when B calls open(), it is another open() in A or M
> that is called ?
# perldoc perlfaq7
[snip]
How do I redefine a builtin function, operator, or method?
[snip]
# perldoc perlsub
[snip]
Overriding Builtin Functions
[snip]
A better practice than the ones above are to use the specific
functions you want as methods on a blessed reference.
# perldoc perltoot
# perldoc perlref
> 2. If yes, can A call the _real_ open(), after possibly doing
> some checks ?
The real open being the perl builtin? You can always get to that with
CORE::open(), as the above mentioned documentation will tell you.
> 3. If yes, can B _somehow_ _still_ call the real open()?
same thing.
> 4. And if yes, can A or M do something so that B can never call
> the real open() ?
No. Perl doesn't limit programmers in that way. It is up to the
programmers that use your packages to only use the stuff you expose.
If they don't honour that contract, there's not much you can do about
it.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Thu, 3 Dec 1998 18:09:25 -0600
From: "Anthony Smith" <anty_84@yahoo.com>
Subject: Checkboxes
Message-Id: <7479c1$g2b$1@blue.hex.net>
This is a multi-part message in MIME format.
------=_NextPart_000_0007_01BE1EE8.0FB63D40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
For some reason this will not work. Its not a syntax error it just isnt =
working the way it should
read(STDIN, $Query_String, $ENV{'CONTENT_LENGTH'});
@namevaluepairs =3D split(/&/, $Query_String);
foreach $namevalue (@namevaluepairs)
{
($name, $value) =3D split(/=3D/, $namevalue);
$value =3D~ tr/+/ /;
$value =3D~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =3D~ s/^( +)//;
$value =3D~ s/( +)$//;
$value =3D~ s/(\t|\r|\n)//g;
$FORM{$name} =3D $value;
}
if ($FORM{'check1'} ne "null") {
$card1 =3D $cards[$card01];
splice @cards, $card1, 1;
print "<td> $card1 </td>";
}
else {=20
print "<td> $card1 </td>";=20
}
------=_NextPart_000_0007_01BE1EE8.0FB63D40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3510.1400"' name=3DGENERATOR>
</HEAD>
<BODY>
<DIV>For some reason this will not work. Its not a syntax error it =
just=20
isnt working the way it should</DIV>
<DIV> </DIV>
<DIV><FONT color=3D#000000 face=3D"Lucida Console" size=3D1>
<P> </P><FONT color=3D#000000 face=3D"Lucida Console" size=3D1>
<P>read(STDIN, $Query_String, $ENV{'CONTENT_LENGTH'});</P>
<P>@namevaluepairs =3D split(/&/, $Query_String);</P>
<P>foreach $namevalue (@namevaluepairs)</P>
<P>{</P>
<P>($name, $value) =3D split(/=3D/, $namevalue);</P>
<P>$value =3D~ tr/+/ /;</P>
<P>$value =3D~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", =
hex($1))/eg;</P>
<P>$value =3D~ s/^( +)//;</P>
<P>$value =3D~ s/( +)$//;</P>
<P>$value =3D~ s/(\t|\r|\n)//g;</P>
<P>$FORM{$name} =3D $value;</P>
<P>}</FONT></P>
<P>if ($FORM{'check1'} ne "null") {</P>
<P>$card1 =3D $cards[$card01];</P>
<P>splice @cards, $card1, 1;</P>
<P>print "<td> $card1 </td>";</P>
<P>}</P>
<P>else { </P>
<P>print "<td> $card1 </td>"; </P>
<P>}</P></FONT></DIV></BODY></HTML>
------=_NextPart_000_0007_01BE1EE8.0FB63D40--
------------------------------
Date: Fri, 04 Dec 1998 01:36:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Checkboxes
Message-Id: <O0H92.58$MF3.251@nsw.nnrp.telstra.net>
In article <7479c1$g2b$1@blue.hex.net>,
"Anthony Smith" <anty_84@yahoo.com> writes:
> This is a multi-part message in MIME format.
Please don't do that. Posting the message once is fine, and plain text
is fine. No need for HTML. This is not the www. if your included text
down below looks crappy, that's because _you_ had some encoding
switched on. And that is how it looks to me.
> read(STDIN, $Query_String, $ENV{'CONTENT_LENGTH'});
CGI, hmm? Not checking to see if you read anything at all, hmm?
{SNIP} of the rest.
Your largest problem is that you are reinventing the wheel, and you're
doing it incorrectly. You should be using the CGI module that comes
with perl.
# perldoc CGI
> if ($FORM{'check1'} ne "null") {
>
> $card1 =3D $cards[$card01];
Where did @cards and $card01 come from?
> splice @cards, $card1, 1;
huh?
You get the value of the $card01 element in @cards, then you use that
as the offset into the same array. Are you using the same array to
store information, _and_ information about where to find other
information?
Do you know what splice does?
# perldoc -f splice
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: Thu, 3 Dec 1998 22:36:04 GMT
From: Gerben_Wierda@RnA.nl
Subject: Fast way to produce block of random bytes?
Message-Id: <F3Eus4.8u5@RnA.nl>
I would like to produce a block of 1024 random bytes. I cannot just use rand
and() and add it to a string, because it will get added as a number, which
means only bytes with values [0-9] will be used. I currently use
$chunk .= pack( "L", rand( 2**31));
until the $chunk is long enough. But this seems pretty slow. Is there a way
to just get the bytes of rand() added to a string without them being
interpreted and added as a number?
--
Gerben_Wierda@RnA.nl (Gerben Wierda)
"If you don't know where you're going, any road will take you there"
Paraphrased in Alice in Wonderland, originally from the Talmud.
"Your io is pretty std" -- Larry Wall
------------------------------
Date: Fri, 04 Dec 1998 00:33:31 GMT
From: Geoffrey Cleaves <gcleaves@bigfoot.com>
Subject: Is this the best possible RegEx?
Message-Id: <36672E19.3D52DEAB@bigfoot.com>
I have a comma delimited data file that can have double-quote enclosed
commas that don't serve as delimeters. For example:
VICE000222 ,"SANTIAGO, CHILE",4,,JUAN NUQEZ,"1,45","",12335
I want to split the line along unenclosed commas. I stumbled on the
following regex by trial and error wich seems to work. However, I'd
appreciate an expert's opinion as to whether this indeed is correct.
Thanks in advance.
split(/(?<="),(?=")|,(?![\w#qQ ]*")|,(?=")|(?<="),/,$line)
------------------------------
Date: Fri, 04 Dec 1998 01:29:53 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Is this the best possible RegEx?
Message-Id: <lWG92.57$MF3.251@nsw.nnrp.telstra.net>
In article <36672E19.3D52DEAB@bigfoot.com>,
Geoffrey Cleaves <gcleaves@bigfoot.com> writes:
> I have a comma delimited data file that can have double-quote enclosed
> commas that don't serve as delimeters. For example:
>
> VICE000222 ,"SANTIAGO, CHILE",4,,JUAN NUQEZ,"1,45","",12335
>
> I want to split the line along unenclosed commas. I stumbled on the
> following regex by trial and error wich seems to work. However, I'd
> appreciate an expert's opinion as to whether this indeed is correct.
> Thanks in advance.
>
> split(/(?<="),(?=")|,(?![\w#qQ ]*")|,(?=")|(?<="),/,$line)
There is a thread going on at this very moment about this very
subject. Do you also read this group, as opposed to just post?
The answer to your question is in the perl FAQ, part 4:
# perldoc perlfaq4
[snip]
How can I split a [character] delimited string except when
inside [character]? (Comma-separated files)
[snip]
replace the first [character with ',' and the second with '"', and you
have your specific question.
Martien
PS. You know that perl is locale sensitive? If you set your correct
locale, perl will know what sort of characters are part of your
alphabet.
# perldoc perllocale
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | 75% of the people make up 3/4 of the
Commercial Dynamics Pty. Ltd. | population.
NSW, Australia |
------------------------------
Date: 4 Dec 1998 01:33:36 GMT
From: Lee.Lindley@bigfoot.com
Subject: Re: Is this the best possible RegEx?
Message-Id: <747e5g$kul$1@rguxd.viasystems.com>
Geoffrey Cleaves <gcleaves@bigfoot.com> wrote:
:>I have a comma delimited data file that can have double-quote enclosed
:>commas that don't serve as delimeters. For example:
:>VICE000222 ,"SANTIAGO, CHILE",4,,JUAN NUEZ,"1,45","",12335
Try Text::ParseWords. It seems to work well with data from
Excel spreadsheets.
:>I want to split the line along unenclosed commas. I stumbled on the
:>following regex by trial and error wich seems to work. However, I'd
:>appreciate an expert's opinion as to whether this indeed is correct.
:>Thanks in advance.
:>split(/(?<="),(?=")|,(?![\w# ]*")|,(?=")|(?<="),/,$line)
I'm not even going to try to read that. It looks like one of Abigail's
signatures.
--
// Lee.Lindley | There was a time when I thought that "being right"
// @bigfoot.com | was everything. Then I realized that getting along
// | was more important. Still, being right is more fun!
// | And if I'm wrong, somebody will get some joy out of telling me!
------------------------------
Date: Thu, 03 Dec 1998 18:27:18 -0500
From: Tripp Lilley <tripp.lilley@perspex.com>
Subject: Re: Memory in Perl
Message-Id: <36671E56.A6EAA662@perspex.com>
Bart Lateur wrote:
> Zenin wrote:
> > Here the memory for $foo and @bar is never reclaimed. Perl expects
> > you're likely to call foo() again and so need that memory again.
> > For efficiency it just reuses the memory it used the first time.
>
> That's silly. There's no way you can retrieve the the previous values of
> those variables, when reentering the block, so there's no point in
> keeping that value.
It's not worried about the /values/, it's worried about the allocated memory
for the variables. It's keeping around the already allocated memory so
it doesn't have to ask for memory /again/, the next time you enter that block.
------------------------------
Date: Fri, 04 Dec 1998 00:02:26 GMT
From: hawkwynd@adelphia.net (Hawkwynd)
Subject: More information defining PODs needed.
Message-Id: <366724e7.118860332@news.fwi.com>
Being a new {really} perl user, (for my CGI web server scripts) I've
begun to realize the actual power Perl has. I'm reading as much on the
materials I have purchased, and so far have yet to grasp the meaning
of the POD files, other than Plain Old Document file.
Others have posted messages here, reporting they have all thier POD
files, located in the /lib/pod directory. I installed 5.0052, on my
windows 98 desktop, as well as my NT workstation, and cannot locate
the POD files, that all are referring to. I've performed web-based
searches, and nothing has provided me with enough information to
specifically explain how to extract the information contained in the
POD files.
Perhaps this post is an annoyance, but I've come to the point where I
am no longer able to find the information I need, and turn to the ng
for assistance in getting more information for the following:
1. Where I can install/download/obtain the remainder of the POD files
for my installation of PERL..
2. How to (command lines) extract or view the information in the POD
files, so that I may learn more about the PERL language from it's
primary source, Perl itself!
3. More information regarding writing perl, styles, and "tactics"
behind writing good code.
Thanks for reading, and having the patience it takes to deal with new
individuals striving to learn more about this lang.
Scott
-------------------------------------------------
Talk about it at Hawkwynd's keep Discussion Forum
http://hawkwynd.tzo.com/discus/index.html
------------------------------
Date: Fri, 04 Dec 1998 01:21:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: More information defining PODs needed.
Message-Id: <rOG92.51$MF3.251@nsw.nnrp.telstra.net>
In article <366724e7.118860332@news.fwi.com>,
hawkwynd@adelphia.net (Hawkwynd) writes:
> files, located in the /lib/pod directory. I installed 5.0052, on my
> windows 98 desktop, as well as my NT workstation, and cannot locate
[snip]
> 1. Where I can install/download/obtain the remainder of the POD files
> for my installation of PERL..
As far as I know, from the posts here in the last few weeks, the
ActiveState perl port, build 507 does come with the pod, and installs
it correctly. It seems that the 502 build didn't do that, which seems
to be leading to much confusion and aggrevation.
Even if the pods are not installed, the documentation should still be
available as html. There's a html directory somewhere. The index.html
in there should provide an entry point to all the documentation.
Note that if you don't have the pod, that 'use diagnostics' won't
work.
You can always access the somewhat outdated perl documentation as HTML
at www.perl.com, but a local copy is much better, faster, and doesn't
require you to be connected to the Internet.
> 2. How to (command lines) extract or view the information in the POD
> files, so that I may learn more about the PERL language from it's
> primary source, Perl itself!
Very commendable indeed :)
Access to the pods on most platforms can be achieved with the perldoc
command.
# perldoc perl
# perldoc perldoc
# perldoc perlfaq
# perldoc -f function-name
# perldoc -q faq-keyword
Of course, perldoc only works if you have the pods installed, so I
urge you to get the ActiveState build 507 or later.
The ActiveState port also builds a tree of html for you, which you can
use. For beginning people this is probably a good thing. Once you get
more familiar with the structure of the perl documentation, you'll
find yourself using perldoc more and more, especially to quickly look
up a function.
> 3. More information regarding writing perl, styles, and "tactics"
> behind writing good code.
# perldoc perlstyle
You could browse through the perl faqs to find some good tactical
things. You could also buy some books. (http://www.perl.com/) has a
good list somewhere. The perl cookbook may be handy for tactics.
> Thanks for reading, and having the patience it takes to deal with new
> individuals striving to learn more about this lang.
We encourage learning. We welcome people who want to know how to find
information.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: Thu, 03 Dec 1998 20:56:36 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Need Perl programming -- please advise...
Message-Id: <comdog-ya02408000R0312982056360001@news.panix.com>
In article <36691549.129086984@news.earthlink.net>, rick@mesagroup.nospam.com (Rick Ciaccio) posted:
> Say we have a 10 room inventory for each of our 7 hotels per day (total 70
> rooms):
>
> 1. How can we keep track of the room inventory?
hook into the existing reservation database.
> 2. Is the reservation number customisable? i.e. can we set it so that we
> can have a different prefix for each hotel?
it's your software. do what you want with it :)
> 3. Do we get a copy of the reservation number when the customer submits
> his reservation?
sure. that should be part of the existing reservation system
anyway.
> 4. What happens if we get more than 10 bookings for that particular hotel
> on a given day?
tell the customer there are no more rooms.
> 5. Can we generate a monthly summary report?
sure.
> 6. How much would it cost to implement the above & how long would it take?
last time i spec-ed one of these the price tag was about $75k. this
assumes that there is already an existing reservation database though,
and that you aren't going to want to use NT. if you need a reservation
database, you should probably just get an off-the-shelf solution, and
then hook up an interface to it.
> We would like the scripts to be totally configurable and flexible so that
> all parameters can be scaled as needed.
yep. that's standard.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 03 Dec 1998 23:12:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Open or Create a file
Message-Id: <ZVE92.12$MF3.212@nsw.nnrp.telstra.net>
In article <746uu1$jso$1@nnrp1.dejanews.com>,
wyndo@cxo.com writes:
> In article <mEx82.798$kx1.868@news.ipass.net>,
> "E. Preble" <preble@ipass.net> wrote:
>> I have a counter, and it needs to update a particular file when it
>> finds it, or else it needs to create the file, chmod it, and then
>> update the counter in it. What is the "create file" command in
>> Perl.
>>
>> Are there security issues with creating files from a script? (no
>> exec commands allowed on my server).
>>
>> E. Preble
>
> Create a file? I use open:
>
> open FILE, ">$filename";
And of course you would check the return value of this open, wouldn't
you?
And in the case of this question, where there's talk of a 'counter',
which just smells like a 'web counter', your approach is wrong,
because it doesn't lock the file.
There have been many posts in this group about this. use dejanews.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | You can't have everything, where would
Commercial Dynamics Pty. Ltd. | you put it?
NSW, Australia |
------------------------------
Date: 4 Dec 1998 00:24:08 GMT
From: "David Fulton" <DFULTON@prodigy.net>
Subject: Question: Ms IIS WWW server releasing resources used by Perl
Message-Id: <01be1fe6$f68e1b80$535b9cd1@03Q04SIA>
Myself and my network administrator are having on ongoing debate about the
efficiency of using Perl as a CGI scripting language. His argument is this:
My Perl script instances are slowly clogging up the NT server (and are not
released) slowly bringing the server to its knees.
My question is are there ways (within my simple Perl scripts) to complete a
program ensuring that the WWW server can release resources, or is the
network adminstrator fated to a) have to reboot the web-server every couple
of weeks or b) persuade my boss to dump Perl as a programming language
altogether?
regards,
Dave
------------------------------
Date: 4 Dec 1998 00:55:51 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Question: Ms IIS WWW server releasing resources used by Perl
Message-Id: <747bun$ejg$1@news.cyberhighway.net>
[Posted and mailed]
In article <01be1fe6$f68e1b80$535b9cd1@03q04sia>,
"David Fulton" <DFULTON@prodigy.net> writes:
> Myself and my network administrator are having on ongoing debate about the
> efficiency of using Perl as a CGI scripting language. His argument is this:
>
> My Perl script instances are slowly clogging up the NT server (and are not
> released) slowly bringing the server to its knees.
NT is notorious for not reclaiming process memory, and for slowly
deteriorating because of it over time. This is not a problem with Perl.
It would happen no matter what language you were programming in.
This is a problem with NT, and probably the web server software.
> network adminstrator fated to a) have to reboot the web-server every couple
> of weeks or b) persuade my boss to dump Perl as a programming language
> altogether?
He's fated to a. Changing languages will not help. Changing web server
software might.
--
Erik Nielsen, Cyberhighway Internet Services NOC
That which hits the fan tends to get flung in all directions.
-- Larry Wall in <199809091801.LAA15194@wall.org>
------------------------------
Date: Fri, 04 Dec 1998 01:26:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Question: Ms IIS WWW server releasing resources used by Perl
Message-Id: <uTG92.55$MF3.251@nsw.nnrp.telstra.net>
In article <01be1fe6$f68e1b80$535b9cd1@03q04sia>,
"David Fulton" <DFULTON@prodigy.net> writes:
> Myself and my network administrator are having on ongoing debate
> about the efficiency of using Perl as a CGI scripting language. His
> argument is this:
>
> My Perl script instances are slowly clogging up the NT server (and
> are not released) slowly bringing the server to its knees.
This may not be a problem with perl, but with the web server software,
and the 'OS'. NT is bad at this sort of stuff. NT is reliably
unstable.
> My question is are there ways (within my simple Perl scripts) to
> complete a program ensuring that the WWW server can release
> resources, or is the network adminstrator fated to a) have to reboot
> the web-server every couple of weeks or b) persuade my boss to dump
> Perl as a programming language altogether?
He will have to reboot regularly, or change OS. I have seen various
unixes run without system degradation for over a year (Solaris,
Ultrix, Linux). I have seen one occurrence of a heavily loaded
database server on Solaris, running for 500 days, at which time it
needed to be rebooted because of an OS upgrade. I have seen heavily
loaded web servers up for over a year, on Solaris.
I still have to see the first NT server that has been running under
reasonable load for more than a month. I still have to hear about it.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Think of the average person. Half of
Commercial Dynamics Pty. Ltd. | the people out there are dumber.
NSW, Australia |
------------------------------
Date: Thu, 03 Dec 1998 20:30:44 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Random integer numbers (1,2,3,4,5....,.....) HOW???
Message-Id: <comdog-ya02408000R0312982030440001@news.panix.com>
In article <747183$lop$1@sun4000.casema.net>, "Marcel Ouwendijk" <mouwend@casema.net> posted:
> I know that there is a function 'rand(value)' but it returns floating point
> numbers. But i need a whole integer nummer somwhere between 1 and 15.
int(), perhaps ?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 3 Dec 1998 19:57:49 -0500
From: "John Zeng" <john_z@hotmail.com>
Subject: Re: Reading a text file & putting into variables
Message-Id: <747c3s$ppk$1@ash.prod.itd.earthlink.net>
thank you very much for your help and explanations!
------------------------------
Date: Thu, 03 Dec 1998 23:39:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Regex question
Message-Id: <6jF92.20$MF3.212@nsw.nnrp.telstra.net>
In article <36671114.1F20A56D@hobbes.clarity.ca>,
Andy Sharp <asharp@hobbes.clarity.ca> writes:
> Two steps, first line by line:
You do realise that the perl FAQ has a better answer to this? See Tad
McClellan's post in the same thread.
> open(FILE, $filename)
no terminating ;. No check to see if the open succeeded.
> while(chomp($n = <FILE>)){ #splits a file on a new line, and removes
> the \n on the end
You should check for defined here. This code will complain under -w.
It will attempt to chomp an undefined value.
> $n = s/\"//g; #Get rid of those quotes (unless you have ","'s
> in your data)
> @fields = split (/,/,$n); #split the data on commas
The purpose of those quotes in files like these is to make sure that
you can distinguish a separator character in a field from a separator.
1,"Some field with a , in it",12
This should split in three parts. Your code will split it in four.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Thu, 03 Dec 1998 23:32:54 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: signals on Windows nt
Message-Id: <GcF92.18$MF3.212@nsw.nnrp.telstra.net>
In article <36671420.DBDD1FF1@mail.uca.edu>,
Cameron Dorey <camerond@mail.uca.edu> writes:
> [cc'd to fnb]
>
> Fernando Nunez Benito wrote:
>>
>> Hi all,
>> I finished implemented a monitoring program for different unix platforms
>> and when I tried to port it to Winndows NT, I realised "frok()" function
>> was not implemented (surprising) and signals didn't work.
>
> Well, "frok()" is not implemented on WinNT, however, "fork()" is.
In perl for win32 however, this is not generally true. ActiveState's
port seems to be the most used:
http://www.activestate.com/support/faqs/win32/perlwin32faq5.html#Certain_functions_don_t_seem_to_
[snip]
There are several functions that are unimplemented in the Perl for
Win32 system. Primary among these are alarm() and fork()
[snip]
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: Thu, 03 Dec 1998 23:10:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: system call
Message-Id: <JTE92.10$MF3.212@nsw.nnrp.telstra.net>
In article <746p0n$dlb$1@cscnews.csc.calpoly.edu>,
"Raj Singh" <rsingh@polymail.calpoly.edu> writes:
> It works, but I don't understand what is the difference between using system
> or backward single quotes.
Have you tried to find out what the difference is by reading the
documentation? I hope you're not going to ask us next week what the
difference between exec and system is, or between substr and split.
Questions like that are best resolved by reading the manual.
# perldoc -f system
[snip]
This is I<NOT> what you want to use to capture
the output from a command, for that you should use merely backticks or
C<qx//>, as described in L<perlop/"`STRING`">.
[snip]
So, one difference is that backticks capture the output, system
doesn't, and that is the difference you want.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Thu, 03 Dec 1998 20:49:12 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Tool to reverse engineer perl code
Message-Id: <comdog-ya02408000R0312982049120001@news.panix.com>
In article <744g8p$7e7$1@bcarh8ab.ca.nortel.com>, "Steve Walsh" <swalsh@americasm01.nt.com> posted:
> Has anyone on this list come across a reverse engineering tool that will
> take perl code as input and generate data diagrams, process diagrams
> (flowcharts), etc. I know that there are lots of software tools available
> that do this for Java, C++, etc but I would like to find one that I can use
> with perl or is customizable to allow me to add perl in as a supported
> language.
that would be kinda wierd unless you forbid certain types of code, such
as using references, eval(), and so on.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 03 Dec 1998 14:44:30 -0500
From: Tricia Weiler <tweiler@ford.com>
Subject: Using formats in Perl
Message-Id: <3666EA1E.6C4C38D7@ford.com>
I am trying to use two formats to write out to one file.
Since the filehandle has to match the format name, how do you do it?
Here's a sample:
open FORMAT1, '>>outfile.txt';
but, I also want to use FORMAT2 to write to the same file.
Can anyone help?
Thanks.
Tricia Weiler
TWEILER@FORD.COM
------------------------------
Date: Thu, 03 Dec 1998 23:53:30 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Using formats in Perl
Message-Id: <_vF92.23$MF3.212@nsw.nnrp.telstra.net>
In article <3666EA1E.6C4C38D7@ford.com>,
Tricia Weiler <tweiler@ford.com> writes:
> Since the filehandle has to match the format name, how do you do it?
Does it?
# perldoc -f write
Writes a formatted record (possibly multi-line) to the specified
FILEHANDLE, using the format associated with that file. By
default the format for a file is the one having the same name as
the filehandle, but the format for the current output channel (see
the C<select()> function) may be set explicitly by assigning the
name of the format to the C<$~> variable.
# perldoc -f select
And you certainly want to read
# perldoc perlform
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd. | things get worse.
NSW, Australia |
------------------------------
Date: Thu, 03 Dec 1998 18:25:06 -0500
From: Tripp Lilley <tripp.lilley@perspex.com>
Subject: Re: Using RCS in Perl scripts
Message-Id: <36671DD2.E308ED15@perspex.com>
Brendan O'Dea wrote:
> Note that this is indistinguishable from 1.004 to Perl's version checks
> (which may be a good thing), and the suffix no longer sorts correctly
> given M.m.B.b where either B > 2 or b > 50. Others may have better
> solutions.
I have to apologize first for not yet having exhaustive design notes to post.
However, I have been considering the problem of version management
and version comparison (and rules for same) a lot over the past couple
of months, and have a few sexy ideas. None of them come to mind in
time for this post, sadly. <sigh>
However, the essence of my approach is to defer version comparison
to a module (not unlike DBI::* and the new VCS::* tree) that acts as
a registry for version information. Different packages would use their
own version rules that depended largely on whatever policies they had
already. Those policies might come from the VCS they're using, or
from decades of "doing it that way", or whatever.
The "version string" (presumes that all versions can be canonicalized
into a string, which, IMHO, is a necessary presumption) contains all
of the information necessary to determine the ruleset to use to compare
versions, and the actual version itself. Thus, given two version strings
that invoke the same ruleset, and the module that implements that
ruleset, you ought to be able to get either simple (boolean) or rich
information about the compatibility of the versions.
All 'rules' modules would support simple boolean comparison, and
modules for which it made sense would also support rich comparison.
A simple example:
-- cut --
package Foo;
use strict; # just to prove I'm good.
use ExtUtils::Version;
use vars qw( $VERSION );
$VERSION = ExtUtils::Version::version "RCS// $Revision: 1.0.2.2.1.2.34$";
-- cut --
The main way in which this differs from Brendan's offering is that it
doesn't explicitly force one to set the package name in the /code/, but
in the data. This means, for instance, that packages can share version
information like so:
-- cut --
package Shared;
use strict; # who cares about bandwidth? strict is important!
use ExtUtils::Version;
use vars qw( $VERSION $BUNDLE_VERSION );
$BUNDLE_VERSION = "RCS// $Revision: 1.0.2.2.1.2.34$";
$VERSION = ExtUtils::Version::version $BUNDLE_VERSION;
-- cut --
package Foo:
use strict; # See? I'm consistent.
use ExtUtils::Version;
use vars qw( $VERSION );
$VERSION = ExtUtils::Version::version $Shared::BUNDLE_VERSION;
-- cut --
Now, changing from RCS-style version comparison to, say, one based
on "labels" and a datafile mapping of labels and compatibility among
labeled releases would be trivial (assuming, of course, that the "label"
library existed :-) ).
Now, this, too, requires work on MakeMaker and CPAN and so forth.
I'm not familiar enough with the innards of the beast itself (ie: perl) to know
what it does with $VERSION. (Is it silly that I have this much opinion on
versioning, and yet I don't know much about what perl does with it
internally? Sure is!)
The principle advantage that I see to this 'registry'-based approach is
that it's effectively infinitely extensible. Anyone can write version comparison
rules that make sense in their environment, and those rules will be used
uniformly by the package building, distribution, and management tools
(including ones not yet conceived, and those that don't yet seem to do
too much with the version info, ie: ppm.pl). If we can get perl itself to use
the version rules libraries, then we can write programs that are much
more tolerant to inter-version differences.
Oh, I forgot to describe some possible 'rich' scenarios. Keep in mind
that most of what I do is write large applications in Perl, so some of these
are geared towards that -- where load time is less of an issue than
footprint and so forth.
Using the 'rich' option, a version string (like "RCS/rich/ $Revision: 1.0$")
would instruct the rules system to invoke scary, probably complex "rich
comparison and recovery" rules. For instance, the following use statement
use Foo ( VERSION => "RCS/rich/$Revision: 1.0$" );
could cause perl to first search for any library named 'Foo', then, from
that result set, ask each of them to score themselves against the version
string. It would take the instance that returned the highest score. But,
wait, it doesn't end there! On load, then, if Foo were so written, it could
transform itself to be /exactly/ what the program expects of version 1.0.
Talk about backwards compatibility! That is to say, if you have code
that expects a particular interface, and that interface changes between
versions, the way we often do it now is to mark the old interface
'deprecated' in the documentation, and use the old names as lightweight
wrappers around the new methods.
Instead, a Foo written with 'rich' versioning might respond to the difference
in versions by loading a translation table, renaming its functions through
a Filter::* module, then handing back to perl's loader.
At the same time, it could issue warnings (a la Java, sorry, but I don't hate
it :-) ) about the deprecated functions, and their new counterparts (heck,
there, we'd be ahead of Java! I mean, javac requires you to look up the
docs for the deprecated function, and /those/ point you to the new function.
Instead, in our system, the rich version-checker could just spit out
"Hey, 'do_something_naughty' has been replaced by 'do_something_nice'
in version 1.02".
Furthermore, when it's time to actually /retire/ the functions, the rich ruleset
might die, telling you not just that the function is gone, but that it was
deprecated in a particular release, and has been replaced, but the
replacement is so radically different that you should consider rewriting.
But what's important to point out here is that the 'rich' rulesystem is not
BUILT IN to perl, or in any way rigorously specified. The only thing
'built in' is a chance to hook a more robust version comparison engine,
and perhaps some shared state variables that BEGIN blocks in the
module can hook to do any fancy-schmanciness that they want to do
with the rich rules.
Rich rules imply that the rulesystem module author has taken the time to
consider what sort of 'extra' functionality they want in their ruleset,
and have coded it "well enough" for their purposes. Thus, rich rules might
simply be warnings that could just as easily be generated with a well
written filter, or they might be over-the-net auto-updaters that grab
the latest version and build it for you! The possibilities are quite unlimited,
as the rulesystems are written in Perl! :-)
By far the most immediately useful part, though, is just the 'simple'
rulesystems, that allow one a more robust mechanism for comparing
versions. Those are what I need for starters :-)
In the tradition of the IETF, I plan to introduce 'working code' (for all
but that which requires perl internals spelunking), but I have to be
brutally honest and say that it might be early January before I get
enough spare cycles to put into it. I already have several modules in
production that I'd like to get out to CPAN before year-end.
------------------------------
Date: Thu, 3 Dec 1998 19:13:38 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: variable inside variable
Message-Id: <F3ELEq.43I@news.boeing.com>
In article <3665947F.9240A9C9@unlinfo.unl.edu>,
quinn coldiron <qcoldiro@unlinfo.unl.edu> wrote:
>I'm working on a database with a table of names and a table of form
>letters.
>What I want to do is place variables in the form letter like this:
>
>------------------------------------------
>$fname $lname
>$address
>
>
>Dear $fname,
>
>blah blah blah
>
>Thank you,
>
>Quinn
>------------------------------------------
>
>I read the formletter into $formletter, set the variables from the table
>and print,
>but I dont get the data, just the variable names. Can I do this?
>
Here're a couple of ways that avoid the use of C<eval>:
my $letter = <<'END';
Dear %s %s
etc.
END
printf $letter, $fname, $lname;
or, (perldoc perlform for more info):
format STDOUT =
Dear @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
"$fname $lname"
etc.
.
write;
hth,
--
Charles DeRykus
------------------------------
Date: 03 Dec 1998 16:22:11 +0000
From: Kin Cho <kin@symmetrycomm.com>
Subject: Win32::API: maximize window vertically?
Message-Id: <ur9uhb3gs.fsf@server3.symmetrycomm.com>
Hi,
I wanted to write a perl utility that can vertically maximize any window
in the WINNT desktop.
Somebody please post some code that does this or something similar
to get me started.
Thanks a lot.
-kin
------------------------------
Date: Thu, 03 Dec 1998 20:35:19 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: wwwboard crash prevention (i hope)
Message-Id: <comdog-ya02408000R0312982035190001@news.panix.com>
In article <3666C4E0.5590@geocities.com>, nospam23_skidoo@geocities.com posted:
> as mentioned earlier, i found that i could crash wwwboard by getting
> three people to submit a message at the same time. one of the things
> that we noticed was that two of us got given the same message number on
> the feedback screen although only one of them survived the process the
> other presumably overwritten or never created in the first place.
this is because the author did not use proper file locking and doesn't
check the return values of open(). of course, there are other
questionable practices that might indeirectly affect this as well.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 03 Dec 1998 20:47:47 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: wwwboard question - file locking
Message-Id: <comdog-ya02408000R0312982047470001@news.panix.com>
In article <linberg-0312981029000001@ltl1.literacy.upenn.edu>, linberg@literacy.upenn.edu (Steve Linberg) posted:
> In article <36667C6A.7609@geocities.com>, nospam23_skidoo@geocities.com wrote:
> > i've got wwwboard running and am having occasional crashes. after a bit
> > of testing i found that it crashes when a few people all post at exactly
> > the same time.
>
> wwwboard does this, and I believe that the problem is more complicated
> than simply locking files. It has no facility for handling simultaneous
> accesses.
it has as much facility as any other CGI script. this is basically
the hit counter problem, and properly written hit counters work fine :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4355
**************************************