[13078] in Perl-Users-Digest
Perl-Users Digest, Issue: 488 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 12 17:07:13 1999
Date: Thu, 12 Aug 1999 14:05:12 -0700 (PDT)
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, 12 Aug 1999 Volume: 9 Number: 488
Today's topics:
Re: A good tutorial PERL <cassell@mail.cor.epa.gov>
Re: Active state perl and IIS3 mixed asp/perl environme <cassell@mail.cor.epa.gov>
Re: get data from flat file <makkulka@cisco.REMOVETHIS.com>
Re: JavaScript recieving variables from Perl <tbesiktasli@gmx.net>
Re: Looking for a good Perl Book <cassell@mail.cor.epa.gov>
LWP munging data <jerrad@networkengines.com>
Re: LWP munging data (Eric Bohlman)
Re: LWP munging data <jerrad@networkengines.com>
PERL for Win32 <UniversalExport@email.msn.com>
Re: PERL for Win32 ajhunter@iquest.net
Perl novice needs quick help pcrev@my-deja.com
Re: Perl novice needs quick help (Greg Bacon)
Re: Perl vs. ASP: which is better? (I R A Darth Aggie)
perlcc undefined symbol: PL_op_desc <david@coppit.org>
Re: Problem Connecting To a remote database <cassell@mail.cor.epa.gov>
Re: Regexp newbie <cassell@mail.cor.epa.gov>
Review for Algo. in Perl senthilr@email.com
Re: s/// and interpolation <chris_conway@my-deja.com>
Re: Search algorithm in Perl (Donovan Rebbechi)
Re: Sending mail to "QuestionExchange" <cassell@mail.cor.epa.gov>
Re: Sesssion ID (Benjamin Franz)
Re: Sesssion ID (I R A Darth Aggie)
Re: Sesssion ID (J. Moreno)
Re: Sesssion ID <tchrist@mox.perl.com>
Re: Sesssion ID <uri@sysarch.com>
Re: Starnge DBI behavior (Eric Bohlman)
Re: suggestions for CRAP <cassell@mail.cor.epa.gov>
Re: while loop teminates too early (Larry Rosler)
Re: Win32 Perl won't display HTML <stirling@banet.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 12 Aug 1999 13:16:27 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: MELERO <melero@ctv.es>
Subject: Re: A good tutorial PERL
Message-Id: <37B32B9B.AE3D7E11@mail.cor.epa.gov>
[courtesy e-mail cc sent to poster]
MELERO wrote:
>
> HI
>
> I ned a good tutorial for PERL , I have found some tutorial but it's very
> bad.
I think that you might want to investigate:
http://www.netcat.co.uk/rob/perl/win32perltut.html
which, despite the filename, is not win32-centric. You might
also want to visit www.perl.com , click on the SEARCH button,
and enter the keyword 'tutorial' to see a list of other URLs.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 12 Aug 1999 13:49:29 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Active state perl and IIS3 mixed asp/perl environment
Message-Id: <37B33359.89CF6D87@mail.cor.epa.gov>
Jon Peterson wrote:
>
> Maurice Walshe <maurice.walshe@bt.com> wrote:
>
> > I am trying to improve performance as the server is slow - due to NDA
>
> > the asp part sets up a transaction but when the perl cgi program is
> > called there seems to be an immense delay in the perl program running.
> > Obviously this causes asp re quest to stackup in the queue causing problems.
>
> Hi. It is quite possible that it is the CGI overhead in launching the perl
> scripts that is causing the problem. If you don't want to use ActiveState's
> solutions to this (they have some, but they may well require IIS4 and rather
> tight integration), then Velocigen's product may help you:
>
> www.velocigen.com
Actually this is one of a number of options. You can also
check out FastCGI, PerlEx from ActiveState, and a couple other
options which are discussed in the Perl FAQ. If you don't have
a copy of the Perl FAQ, then you really ought to upgrade your
version of Perl [at least a private version if nothing else],
becaue it and a *lot* of other helpful docs come with it.
For free.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 12 Aug 1999 12:58:17 -0700
From: Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com>
Subject: Re: get data from flat file
Message-Id: <37B32759.B4E26840@cisco.REMOVETHIS.com>
mikej wrote:
> [ after snipping ] the script should go through each line
> of the data file looking for a match for the text string and then > >return all the variables on the same line.
> [ snipped..]
> it only works for the first line.
> foreach $line (@indata)
> {
> chomp($line);
> ($data_name, $data_username, $data_password) = split(/\|/, $line);
> if ($data_name eq $clientname) {
> $username = "$data_username";
> $password = "$data_password";
> }
> }
You need to use arrays instead of scalars $username and $password
if you expect to find a match on multiple lines.
foreach $line ( @indata )
{
# chomp () and split () ;
if ( $dataname eq $clientname )
{
push ( @username, $data_username );
push ( @password , $data_password);
}
}
In your results you then print out the arrays @username and @password.
--
------------------------------
Date: Thu, 12 Aug 1999 22:57:49 +0200
From: "T. Besiktasli" <tbesiktasli@gmx.net>
Subject: Re: JavaScript recieving variables from Perl
Message-Id: <7ovcn5$27a$1@news.online.de>
perhaps not the best and elegant idea but:
print "content-type: html/text\n\n";
print
"<html><head><title>lala</title></head>";
print "<script
language=\"javascript\">";
print "<!--";
print "var variable1 = 12345;";
print "//-->";
print "</script>";
print "</head>";
well well..maybe there is a better way....and I dunno if this works in
actuality....let me know!
Tolga
>how do I have JavaScript read variables from a Perl file. For example, I
>have a database of variables, how can I load those into JavaScript? Load
>them without rewriting the page would be the best but if that's not
possible
>that's ok....
>
>Thanks in advance,
>David
>
>
------------------------------
Date: Thu, 12 Aug 1999 14:03:05 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Looking for a good Perl Book
Message-Id: <37B33689.63C64A3A@mail.cor.epa.gov>
Elaine -HFB- Ashton wrote:
> Abigail wrote:
[big snip]
> > We all whine about the people asking question here that are found in the
> > faq, or the manual. But sometimes we should realize it isn't easy to
> > find things.
>
> This is very true as sometimes, when I'm double checking something to
> make sure I'm answering a question correctly, it takes me more effort to
> find the information. Some stuff is intuitive and obvious, some is
> obscure and you really have to read all several hundred pages of the
> pods to know where to look. I still think a cross-referenced index would
> serve the documentation well.
At least. Yesterday I was answering a question about CSV files.
I typed something along the lines of: "perldoc -q comma" and then
checked that I was right. It didn't get the appropriate FAQ in
a usable form in the querent's OS [win98]. I tried a number of
alternatives, including "perldoc -q separated" and finally got a
hit on "perldoc -q delimited" which is the wrong way to describe
the file in the first place! Uggh.
Are we going to be reduced to having to explain to win32 users
how to 'grep the pods' every time?
> My K&P is right next to vol 1 & 2 of Bell Labs "Unix Programmer's
> Manual" on my bookshelf....yellow and decaying but still great books.
> Most of my O'Reilly's and other books are outdated or seem to be anyway.
I have a few O'Reilly's which don't seem to be out of date.
Perl Cookbook
Advanced Perl Programming
Practical C Programming
[I don't own the Perl5 version of Learning Perl or L.P. for Win32]
Oddly enough, all the books/manuals I have from Sun are at least
partly out of date now. :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 12 Aug 1999 16:09:24 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: LWP munging data
Message-Id: <37B329F4.521EABB6@networkengines.com>
I'm trying to retrieve a binary by:
use LWP::simple;
$foo = get("http://www.xxx.yyy/bar.zip");
but $foo comes out with \r's inserted, thereby corrupting the archive.
Any ideas?
------------------------------
Date: 12 Aug 1999 20:24:17 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: LWP munging data
Message-Id: <7ovahh$jos@dfw-ixnews13.ix.netcom.com>
jerrad pierce (jerrad@networkengines.com) wrote:
: I'm trying to retrieve a binary by:
: use LWP::simple;
: $foo = get("http://www.xxx.yyy/bar.zip");
:
: but $foo comes out with \r's inserted, thereby corrupting the archive.
: Any ideas?
I very much doubt that LWP is doing anything to your data. I suspect
that you're running on a Win32 system and after you've retrieved the data
using LWP, you're writing it to a file that hasn't been binmode()'d.
*That* will cause the problem you're experiencing; the I/O routines in
the C runtime library that perl calls will translate a bare \n into \r\n
unless told not to.
------------------------------
Date: Thu, 12 Aug 1999 16:48:49 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: Re: LWP munging data
Message-Id: <37B33331.31EDDB6D@networkengines.com>
Thanks! Not intuitive. UN*X has text and bin files, and you don't have to worry about that crap. Yet windows w/o bin and txt files you do.
------------------------------
Date: Thu, 12 Aug 1999 15:14:35 -0700
From: "Deane Barker" <UniversalExport@email.msn.com>
Subject: PERL for Win32
Message-Id: <OgBAn#P5#GA.121@cpmsnbbsa03>
This is a multi-part message in MIME format.
------=_NextPart_000_000C_01BEE4D5.6383C6A0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
I've downloaded the stable release of PERL for Win32, but I can't figure =
out what to do with it. I unzipped it, but the documentation just =
doesn't make sense. What file do I run? CONFIGURE doesn't do anything, =
and I can't find an INSTALL file.
I'm learning to program PERL on a Unix box at work, and I'm really =
enjoying it so I'd like to get it running on my Win95 machine at home.
Can anyone help?
Deane
------=_NextPart_000_000C_01BEE4D5.6383C6A0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D3>I've downloaded the stable release of PERL for =
Win32, but I=20
can't figure out what to do with it. I unzipped it, but the =
documentation=20
just doesn't make sense. What file do I run? CONFIGURE =
doesn't do=20
anything, and I can't find an INSTALL file.</FONT></DIV>
<DIV> </DIV>
<DIV>I'm learning to program PERL on a Unix box at work, and I'm really =
enjoying=20
it so I'd like to get it running on my Win95 machine at home.</DIV>
<DIV> </DIV>
<DIV>Can anyone help?</DIV>
<DIV> </DIV>
<DIV>Deane</DIV></BODY></HTML>
------=_NextPart_000_000C_01BEE4D5.6383C6A0--
------------------------------
Date: Thu, 12 Aug 1999 20:55:29 GMT
From: ajhunter@iquest.net
Subject: Re: PERL for Win32
Message-Id: <5xGs3.29$h4.141@news1.iquest.net>
This is a multipart message in MIME format.
--=_alternative 00730945052567CB_=
Content-Type: text/plain; charset="us-ascii"
Go to http://www.activestate.com and get the latest Active Perl. You will
be glad you did.
Tony
--=_alternative 00730945052567CB_=
Content-Type: text/html; charset="us-ascii"
<br><font size=2 face="sans-serif">Go to http://www.activestate.com and get the latest Active Perl. You will be glad you did.</font>
<br>
<br><font size=2 face="sans-serif">Tony</font>
--=_alternative 00730945052567CB_=--
------------------------------
Date: Thu, 12 Aug 1999 20:20:38 GMT
From: pcrev@my-deja.com
Subject: Perl novice needs quick help
Message-Id: <7ovaaa$lgg$1@nnrp1.deja.com>
Hi, I'm pretty new to the world of perl, and I am building a script, in
which I need to create a new page which is based upon a template, where
the data from my form will be inserted into parts of the template. I
have so far managed to make it create the file, but I am unsure as of
how to put the data into the template and put it into the page. Please
could you share some of your expertise and possibly show me how this
could be done?
Many thanks
Pete Williams
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 12 Aug 1999 20:38:48 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Perl novice needs quick help
Message-Id: <7ovbco$bih$1@info2.uah.edu>
In article <7ovaaa$lgg$1@nnrp1.deja.com>,
pcrev@my-deja.com writes:
: Subject: Perl novice needs quick help
Why are you posting to Usenet if you need quick help?
: Hi, I'm pretty new to the world of perl, and I am building a script, in
: which I need to create a new page which is based upon a template, where
: the data from my form will be inserted into parts of the template. I
: have so far managed to make it create the file, but I am unsure as of
: how to put the data into the template and put it into the page.
I searched the CPAN modules list[*] for template and found these:
CGI JMOORE CGI-FastTemplate-1.09.tar.gz 13k 28 Jun 1999
HTML BRIANNG HTML-DynamicTemplate-0.94.tar.gz 4k 09 Jul 1999
HTML SAMTREGAR HTML-Template-0.04.tar.gz 23k 18 Jun 1999
Text DCARRAWAY Text-BasicTemplate-0.9.8.tar.gz 9k 14 Jun 1999
Text MJD Text-Template-0.1b.tar.gz 9k 25 Jan 1996
Text MJD Text-Template-1.20.tar.gz 26k 08 Mar 1999
XML GHUTCHIS XML-Template-1.0.1.tar.gz 8k 21 Jul 1999
[*] <URL:http://www.perl.com/CPAN/modules/01modules.index.html>
Good luck,
Greg
--
There's always been Tower of Babel sort of bickering inside Unix, but this is
the most extreme form ever. This means at least several years of confusion.
-- Bill Gates
------------------------------
Date: 12 Aug 1999 20:12:24 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Perl vs. ASP: which is better?
Message-Id: <slrn7r6ap9.i98.fl_aggie@thepentagon.com>
On 12 Aug 1999 19:25:19 GMT, Kent Delcastillo <delcasti@cs.fsu.edu>, in
<7ov72v$43l$1@news.fsu.edu> wrote:
+ I'm curious to know what everyone thinks.
Perl, obviously, since it isn't tied to a web server. Particularly a
webserver like IIS...
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Thu, 12 Aug 1999 16:51:04 -0400
From: David Coppit <david@coppit.org>
Subject: perlcc undefined symbol: PL_op_desc
Message-Id: <Pine.GSO.4.05.9908120913400.1637-100000@mamba.cs.Virginia.EDU>
So I installed Perl 5.005_60 to see how far perlcc has come along... When I
tried to compile a "hello world" program, I got the following error:
Can't load '/home/david/perl/lib/5.00560/i686-linux/auto/B/B.so' for module B:
/home/david/perl/lib/5.00560/i686-linux/auto/B/B.so: undefined symbol:
PL_op_desc at /home/david/perl/lib/5.00560/i686-linux/DynaLoader.pm line 172.
at /home/david/perl/lib/5.00560/i686-linux/O.pm line 2
BEGIN failed--compilation aborted at
/home/david/perl/lib/5.00560/i686-linux/O.pm line 2.
BEGIN failed--compilation aborted.
ERROR: In generating code for a.pl!
Anyone have a suggestion on how to resolve this?
Thanks,
David
_________________________________________________________________________
David Coppit - Graduate Student david@coppit.org
The University of Virginia http://coppit.org/
"Yes," said Piglet, "Rabbit has Brain." There was a long silence.
"I suppose," said Pooh, "that that's why he never understands anything."
------------------------------
Date: Thu, 12 Aug 1999 13:45:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Problem Connecting To a remote database
Message-Id: <37B3324C.5F38BCD4@mail.cor.epa.gov>
Nikos Mavrogiannakis wrote:
>
> We are trying to connect to a remote database (Oracle 7 - AIX) via sql
> net from a Win Nt server. We wrote a script using win32::ODBC modules.
> The problem is that we can connect to the database running the script
> from MS-DOS prompt but we cannot access the database through World Wide
> Web. We tried to achieve a connection creating User, System and file
> DSN's with the ODBC Administrator but we have the same problem (Actually
> the file DSN doesn't work at all - the script seems that it cannot
> recognise a file DSN ).
> We would appreciate your help.
Without seeing a small, illustrative example of your code [no
more than 30 lines], it is pretty hard to tell what is wrong.
But my copy of the PSI::ESP module says.. umm... Hmmm. Are
you trying to access your file via the web as if you were
accessing a normal file in a local directory? You have to
use the HTTP protocol to get at files over an intranet, just
like you do over the internet.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 12 Aug 1999 13:14:32 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Regexp newbie
Message-Id: <37B32B28.21CC5119@mail.cor.epa.gov>
Abigail wrote:
[snip]
> Yes. It's amazing, but true! For only 5 monthly payments of $29.94 (yes,
> we are cheaper than Python, who charges you the incredible $29.95)
> you too can be the proud owner of the Perl manual! Starting 6 weeks
> after receiving the initial you will receive your first pod page!
> And then every week another pod! And if you don't like the first pod,
> send it back and we will stop sending you more pods! No questions asked!
> But you don't want to send back the pod! You will love the pod! The kids
> will love the pod! The kids will ask you "when is the new pod coming?"!
> If you don't want your kids to grow pimples and do bad in school, you
> can give them pods! Be a responsible parent! And parents love the pods
> too! For the kids, there is much to learn about ``reverse'' and ``chomp'',
> and for the parents, there are ``Threads'' and ``Regular Expressions''!
>
> Don't delay! Order now!
>
> Please call our toll free number: 1-800-POD-PERL, 24h/day!
The scary thing is that you could probably market this on a
website and "MAKE $$$$ FAST" at it. I suspect that plenty
of the clue-challlenged would bite.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 12 Aug 1999 20:14:37 GMT
From: senthilr@email.com
Subject: Review for Algo. in Perl
Message-Id: <7ov9v2$lb2$1@nnrp1.deja.com>
Hi:
Is anyone reviewing the new book
"Algorithms in Perl.."
Thanks,
..Senthil.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 12 Aug 1999 20:03:42 GMT
From: Christopher Conway <chris_conway@my-deja.com>
Subject: Re: s/// and interpolation
Message-Id: <7ov9an$ksp$1@nnrp1.deja.com>
In article <37b30573@cs.colorado.edu>,
tchrist@mox.perl.com (Tom Christiansen) wrote:
> In comp.lang.perl.misc,
> linberg@literacy.upenn.edu (Steve Linberg) writes:
> :You should NEVER eval a string from user input.
>
> The Safe->reval() method, however, is admissible.
Perhaps you would be willing to offer a brief demonstration
of how Safe could be used on this example? (I looked over
the Safe manpage and it confused me quite a bit.)
Chris
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 12 Aug 1999 17:03:42 -0400
From: elflord@news.newsguy.com (Donovan Rebbechi)
Subject: Re: Search algorithm in Perl
Message-Id: <slrn7r6dld.gm0.elflord@panix3.panix.com>
On Thu, 05 Aug 1999 02:09:06 GMT, Dheera wrote:
>Hi,
> I'm trying to build a search-engine (in Perl) which can search about
>1 million database records in less than 1 second (if possible) on my hz
>Pentium II.
As long as your data is sorted, you should be OK. If you are
searching sorted data, you can use a binary search. What you *don't*
want to do is check every element. Imagine the difference between looking
someone up in the phonebook ( similar to binary search ) and looking
them up in an unsorted phonebook ( linear ). You get the idea.
Concrete ideas about implementation ? Take a look at the DBFile module,
( which lets you "store" your large hashes on your disk instead of having
them in memory ) and take a look at the information on BTREEs ( which
produce fast query results using binary algorithms )
--
Donovan
------------------------------
Date: Thu, 12 Aug 1999 13:39:25 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Sending mail to "QuestionExchange"
Message-Id: <37B330FD.C276F976@mail.cor.epa.gov>
Tom Christiansen wrote:
>
> These people are a plague. They do not admit who they are. Anonymity
> destroys accountability. They overquote, including sigs and spamvert
> attachments. They give bad answers. Worst of all, they appear to be
> using this newsgroup as a publicity gimmick to sucker people in to
> some pay-per-question commerical venture.
It's even worse than that. Take a quick trip to
www.questionexchange.com if you dare, and look at what the
site's designers are doing. In order to get yourself registered
as an expert in a category, you have to answer a question in
that category. Guess where the questions are coming from?
That's right. From Usenet newsgroups. This may not even be
apparent to the people answering the questions to become
'certified'. I wasn't interested enough to go that far,
just far enough to verify that the answers we have seen from
'QuestionExchange' are in fact from a slew of different people.
So, of course our complaints in this newsgroup have no effect
on the 'poster'. The real author of the reply probably never
sees what we have to say in return! And if one author does
see such replies and fixes his/her posting style in response,
the next author starts out totally in the dark.
> I encourage everyone to send them mail detailing your displeasure
> over their transgressions. A quick killfile entry is perhaps necessary,
> but not sufficienty. Send them mail.
Complain to anyone and everyone. Mail to QuestionExchange
can just go right in one of Mister Gonzalez's ears and out
the other. The posters themselves may be blameless for the
most part, particularly since it is not clear that they are
aware of the source of the questions. And Perl is just one
of a long list of comp topics listed, so this is probably
going on in another 20 newsgroups.
A killfile will only permit this outrage to continue,
unnoticed by the people who can most effectively correct
any glaring errors dropped in by the next, umm, contestant.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 12 Aug 1999 20:07:53 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: Sesssion ID
Message-Id: <tQFs3.122$DI3.11977@typhoon01.swbell.net>
In article <37b31fe0@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>In comp.lang.perl.misc,
> snowhare@long-lake.nihongo.org (Benjamin Franz) writes:
>:Aggie, Tom and Uri write:
>:
>: "We can do it better. Or at least weirder."
[...]
>:As you can see, none of (Tom, Aggie and Uri's) proposals are faster
>:than the _original_ code. I (of course ;) ) was able to improve on
>:it slightly.
>
>So what? Clarity, consistency, and deletion of redundancy
>were my goal. These are much more important then a few nanosecond
>here and there.
>
>The highest virtue of the programmer is to seek out redundancy and
>factor it out.
Tom, the phrase 'explaining the obscure via the even more obscure'
could have been written just for your coding style. Your code is
_denser_ - not _clearer_. If you step back and ask yourself _why_
seeking out redundancy and factoring it out is ('an' - not 'the')
important virtue of a programmer, you will discover your quest for
redundancy elimination by any means is misguided. The goal is to i
save _overall_ cost - not 'one measure of cost before all others'.
Development cost
Execution cost
Maintenance cost
Your style tends to inflate *all* of them. Time for people to
seek 'perfect' solutions over 'good enough' solutions. Time spent
in needlessly complex control structures to save a _few_ bytes
of code for something done only a few times. Time spent by
maintainers understanding and modifying the code.
The highest virtue of a programmer is producing code that does
the required job with the optimum use of all resources to achieve
the task.
The original code is fast (faster than all the alternatives
suggested in this thread with the exception of my own 'show off'
code), quickly created (it took only seconds), clear, quickly
understood and maintained even by novice programmers,
and not excessively long.
IOW: It is _optimum_.
--
Benjamin Franz
"Biida!"
------------------------------
Date: 12 Aug 1999 20:23:37 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Sesssion ID
Message-Id: <slrn7r6be8.i98.fl_aggie@thepentagon.com>
On 12 Aug 1999 19:01:54 GMT, Greg Bacon <gbacon@itsc.uah.edu>, in
<7ov5n2$afb$2@info2.uah.edu> wrote:
+ : TC> for $value ($sec, $min, $hour, $mday) {
+ : TC> $value = sprintf "%02d", $value;
+ : TC> }
+ : sorry, tom, that is too obscure for even the most jaded perl hacker
+ : (except you!). though it is cute code.
+ Please point out the part or parts that are "too obscure".
It is the subtlety that you're also modifying the ( list ) variables
in place. I've read about it in the docs, and I've been bitten by it,
and subsequently steered clear. When I got Tom's CC, I did a "huh?
Ooooo, yeah, that works." In this case, that is the desired behaviour,
and thus a clever usage.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Thu, 12 Aug 1999 16:36:11 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: Sesssion ID
Message-Id: <1dwfihb.1ll1wgg1y92e9dN@roxboro0-0038.dyn.interpath.net>
Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "TC" == Tom Christiansen <tchrist@mox.perl.com> writes:
>
> TC> : $sec = sprintf("%02d",$sec);
> TC> : $min = sprintf("%02d",$min);
> TC> : $hour = sprintf("%02d",$hour);
> TC> : $mday = sprintf("%02d",$mday);
>
> TC> for $value ($sec, $min, $hour, $mday) {
> TC> $value = sprintf "%02d", $value;
> TC> }
>
> sorry, tom, that is too obscure for even the most jaded perl hacker
> (except you!). though it is cute code.
>
> :-)
>
> how about:
>
> ($sec,$min,$hour,$mday) = map sprintf("%02d", $_), $sec,$min,$hour,$mday;
>
> slightly redundant but much clearer IMO. as you know, redundancy in a
> language (like english) is a necessary thing.
I don't grok map very well, but the for loop is obvious. I vote for
that. You want to make it crystal clear then put in some comments.
--
John Moreno
------------------------------
Date: 12 Aug 1999 14:49:40 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Sesssion ID
Message-Id: <37b33364@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
snowhare@long-lake.nihongo.org (Benjamin Franz) writes:
:IOW: It is _optimum_.
You can repeat that it's an optimal all you want, and you still won't
convince me. Proof by repetition fails you, miserably. My way is less
offensively repetitive, and trivially extensible. Yours isn't. What's
next?
$a[$x][$y][$z] = $a[$x][$y][$z] + 1;
--tom
--
"Incrementing C by 1 is not enough to make a good object-oriented language."
(M. Sakkinen, in "On the Darker Side of C++", ECOOP'88)
------------------------------
Date: 12 Aug 1999 17:03:23 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Sesssion ID
Message-Id: <x7r9l867ac.fsf@home.sysarch.com>
>>>>> "TC" == Tom Christiansen <tchrist@mox.perl.com> writes:
TC> [courtesy cc of this posting mailed to cited author]
TC> In comp.lang.perl.misc,
TC> snowhare@long-lake.nihongo.org (Benjamin Franz) writes:
TC> :IOW: It is _optimum_.
TC> You can repeat that it's an optimal all you want, and you still won't
TC> convince me. Proof by repetition fails you, miserably. My way is less
TC> offensively repetitive, and trivially extensible. Yours isn't. What's
TC> next?
TC> $a[$x][$y][$z] = $a[$x][$y][$z] + 1;
but tom, you so often equate perl and english, so why not remove all the
redundancy from english too? i agree the above line is foolish, but that
does not always extend to removal of all redundancy in code. down that
road lies madnes for the sake of a single rule. some redundancy is
useful for clarity. just because soemthing is syntactically and
semantically correct doesn't mean it is the best code for everyone to
read. hence my comment about obsurity. you can write for obsfucated
contests if you wish but no one wants that style in production code. not
everyone knows every trick and rat hole. i am not saying that for's
aliases are obscure but the way you used it was to me. aliasing to $_
and doing implied work on it is fine. but using a named alias for both
an rvalue and lvalue was not immediately crystal clear to me so i
wouldn't do it. it is my choice and you can choose your way. but forcing
a total removal of redundancy for its own sake is to draconian.
i know you probably won't read (and definitely won't followup) so i
write this for others to read. maybe some kind soul will followup and
quote it so you will see it.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: 12 Aug 1999 20:10:21 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Starnge DBI behavior
Message-Id: <7ov9nd$jos@dfw-ixnews13.ix.netcom.com>
Kevin Raison (raison@mc.net) wrote:
: Given the typo corrections below, the odd behavior of fetchrow_arrayref is
: still at issue.
: On each iteration, it is reusing the same memory address for what should be a
: different reference.
Unless the documentation for a function that returns a reference states
that it will return a unique reference on each call, you really can't
assume that you can just squirrel away its return value. You should make
your own copy of what it references and store a reference to *that*.
------------------------------
Date: Thu, 12 Aug 1999 13:12:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: suggestions for CRAP
Message-Id: <37B32AB7.FAEA916F@mail.cor.epa.gov>
Uri Guttman wrote:
[snip of You Know Who]
> amazing. he actually has the chutzpah to show his face here, where he is
> cursed on a daily basis, where his infected code gets trashed because
> all the newbies can't get it to work. remember, he is the god of the
> cargo cult programmers, who keep passing on the religious totems of bad
> cgi parsing, backwhacked quotes, local, and no modules or references.
Well, on the other hand, he's taking this professionally rather
than personally, as too many posters here do. I find his
attitude a pleasant surprise from what I was anticipating.
He is only 19 or 20. He's probably not *married* to the code
he kludged up in the past, when he was teaching himself by
coding.
> well, if we get the CRAP and good cgi sites up and running, his
> cgi-resources could become a desert. and yet he gives us his blessing.
Perhaps he doesn't mind. Perhaps he really would prefer to
have top-notch Perl code available to do the things he did
by hand in sub-optimal ways. Who knows?
> matt: "perl been berry berry good to me"
>
> maybe he will attend monterey and someone (me?) could throw a beer in
> his face like in the ending of the caine mutiny! to the real cause of
> the ruination of c.l.p.misc, matt wright!
"Strawberries." click-click-click...
> so full steam ahead, says old yellowstain, and damn the storm! we will
> make a site full of good cgi to be a lighthouse to guide the web through
> the dark crashing waves of matt's code and out into the calm port where
> larry intended perl to anchor.
I see Matt's code more as the Eryops in the evolution of webcode,
flopping around because no one else has done anything to take
over that evolutionary niche, and unconcerned about its eventual
extinction. Sort of like the Far Side cartoon of the school of
fish with baseball gloves and a bat, staring forlornly at the
baseball just inches above the waterline on shore, with a caption
saying something like "Great moments in evolution."
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 12 Aug 1999 13:58:54 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: while loop teminates too early
Message-Id: <MPG.121cd56a86f724d4989e4a@nntp.hpl.hp.com>
In article <37b4ecf6.17656300@news.skynet.be> on Thu, 12 Aug 1999
15:57:08 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Larry Rosler wrote:
>
> >A valid text file is, by *my* definition, a sequence of sequences of
> >characters, where each sub-sequence is terminated by a newline
> >character. Dangling characters without a terminating newline character
> >are not valid.
>
> Actually, by my definition, a text file is a file that is entirely
> meaningful when looked at with a text editor (or other text viewer). THe
> newline characters serve to SEPARATE the lines, not to TERMINATE them,
> so a final newline at the end isn't striclty necessary.
Actually, though 'vi' can handle such a file, it complains about
'incomplete last line' when the file is loaded in. So something is
amiss with such a file, by my definition, by vi's definition, and (as
the rest of the thread shows) by TomC's definition.
I feel like I'm in good company. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 12 Aug 1999 17:07:11 -0400
From: <stirling@banet.net>
Subject: Re: Win32 Perl won't display HTML
Message-Id: <37b335df@news1.us.ibm.net>
David Cassell wrote in message <37B3289F.1F74D0A7@mail.cor.epa.gov>...
>stirling@banet.net wrote:
>>
>> >Well, it works fine with command level but it won't display HTML output
on
>> >web browser.
>>
>> Check to see if you use the following statement before any HTML
output:
>> print "Content-type:text/html\n\n";
> ^^
>I think you forgot the space after the colon.
yup
>
>> Not having those lines would most definetly cause your script to bug,
>> also if would help if you would give more specific error messages.
>
>And remembering that space will ensure that this works for
>all browsers, and not just those which are used to seeing
>deformed HTML.
>
>HTH,
>David
>--
>David Cassell, OAO cassell@mail.cor.epa.gov
>Senior computing specialist
>mathematical statistician
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 488
*************************************