[11171] in Perl-Users-Digest
Perl-Users Digest, Issue: 4772 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 28 17:07:28 1999
Date: Thu, 28 Jan 99 14:01:36 -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, 28 Jan 1999 Volume: 8 Number: 4772
Today's topics:
Re: Perl Criticism topmind@technologist.com
Re: Perl Criticism topmind@technologist.com
Re: Perl Criticism topmind@technologist.com
perl DBI CGI and mySQL (Mike D.)
Re: Perl's malloc [Gosh, s// faster than m//] (Ilya Zakharevich)
Problems with Win32 perl and odbc.pm <gibsonc@aztec.asu.edu>
Re: Reading headers & LWP <Tony.Curtis+usenet@vcpc.univie.ac.at>
regex lib or Perl linked in? <jimmy@globalSpam.org>
Re: Sorting a file in Perl question :: please help :) <Denis.Haskin@bigfoot.com>
Stopping a foreach loop Ryan.Haman@mci.com
Visual Perl? (THE Groovy)
WinNT Perl 5.005-02: Changed behavior of `dir` after Cy Denis.Haskin@bigfoot.com
Writing my own Email script but not getting it. <bcompson@yahoo.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 28 Jan 1999 20:49:20 GMT
From: topmind@technologist.com
Subject: Re: Perl Criticism
Message-Id: <78qigd$ssa$1@nnrp1.dejanews.com>
In article <slrn7au5am.ivr.dformosa@godzilla.zeta.org.au>,
dformosa@zeta.org.au (David Formosa (aka ? the Platypus)) wrote:
> In article <78lpql$r94$1@nnrp1.dejanews.com>, topmind@technologist.com wrote:
> >In article <78kim7$pi1$1@nnrp1.dejanews.com>,
> > droby@copyright.com wrote:
>
> [...]
>
> >> The problem with our junior language designer's concept here is that if you
> >> lose the short-circuit for this neat trick, you lose the optimization that
> >> led to its availability.
> >
> >Insults like this do not cover the fact that they are unnecessary,
> >and therefore not worth the readability risk.
>
> However optimisations like this have a magour impact in code running
> time and useablity. if ($a != 0 and $b/$a>10) { is not something that
> I can do without. Indeed I would argue that given that these are
> quite commen in most langages most programers will be expecting them
> and therefore a lanague without them would be more confising.
>
I did *not* advocate doing away with short-circuit booleans altogether.
It is using them as alternatives to IF's that I apposed to.
Pre-validating nulls, undefines, and zero divides is an
acceptable use of short-circuit booleans IMO.
> --
> Please excuse my spelling as I suffer from agraphia. See
> http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
> How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html
>
>
-tmind-
http://www.geocities.com/SiliconValley/Lab/6888/langopts.htm
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 28 Jan 1999 21:14:34 GMT
From: topmind@technologist.com
Subject: Re: Perl Criticism
Message-Id: <78qjvh$uap$1@nnrp1.dejanews.com>
In article <MPG.1118dc7a9147f8529899d1@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:
> In article <slrn7au5am.ivr.dformosa@godzilla.zeta.org.au> on 27 Jan 1999
> 13:32:07 GMT, David Formosa (aka ? the Platypus) <dformosa@zeta.org.au>
> says...
> ...
> > However optimisations like this have a magour impact in code running
> > time and useablity. if ($a != 0 and $b/$a>10) { is not something that
> > I can do without.
>
> Certainly you could do without it, as all it is is a sequence of
> decisions:
>
> if ($a != 0) {
> if ($b/$a > 10) {
I did *not* advocate doing away with short-circuiting for
pre-validation of variables as described in another message.
It is using them for general "lazy if's".
>
> > Indeed I would argue that given that these are
> > quite commen in most langages most programers will be expecting them
> > and therefore a lanague without them would be more confising.
>
> Compound conditionals are indeed common and convenient. But they are
> not indispensable. If one were designing a bare-bones, TIOOWTDI
> language, one could leave them out, but not without some pain.
>
> Consider this snippet: Assign the first TRUE result of a set of
> alternative, costly computations (possibly with side effects), or a
> default:
>
> $x = f() || g() || h() || $y;
It is not obvious wether this is to return a boolean
or something else. Very poor form IMO. One would have
to inspect the routines to see what the structure REALLY
is.
>
> This is beautiful, spare, clean Perl (but not C, by the way, where the
Clean, my foot!!!!
> result would be a Boolean!). The following is both Perl and C (ignoring
> variable-naming syntax):
>
> $x = ($t = f()) ? $t : ($t = g()) ? $t : ($t = h()) : $y;
>
> Ouch. Now try that again in a language that doesn't have conditional
> expressions either:
>
> if ($t = f()) {
> $x = $t;
> } elsif ($t = g()) {
> $x = $t;
> } elsif ($t = h()) {
> $x = $t;
> } else {
> $x = $y;
> }
>
Aside from the leaky assignments, this is preferable to
the prior. The case-like structure is obvious to the reader.
Perhaps it is not typer friendly, but it is
more reader friendly.
> As you can see, it gets 'old' really fast. But it certainly can be
> done, and even in assembly language, God forbid!
Define what you mean by "old"? Perhaps it can be rewritten
or reformulated a bit, but without knowing what f() and so
forth do, I could not offer any suggestions at this point.
A case should look like a case, an IF should look like an
IF, and a boolean expression should look like a boolean.
Perl's interchangability of these makes more work for
the reader, period!
>
> Remember the 'Perl baby talk' metaphor in the introduction to the Blue
> Camel (and probably elsewhere)? Fortunately Perl lets those who are
> able to do so talk 'adult talk' also.
Perhaps it is a battle between your fingers and somebody
else's eyes. Perl is ideal for the selfish.
"F your eyes, my fingers are king!"
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Company
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
>
-tmind-
http://www.geocities.com/SiliconValley/Lab/6888/langopts.htm
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 28 Jan 1999 21:19:07 GMT
From: topmind@technologist.com
Subject: Re: Perl Criticism
Message-Id: <78qk81$ufi$1@nnrp1.dejanews.com>
In article <36AF3DE0.73455051@atrieva.com>,
Jerome O'Neil <jeromeo@atrieva.com> wrote:
> topmind@technologist.com wrote:
>
> > > That still draws more attention to the error instead of to the opening
> > > of the file.
> >
> > How so? Because it starts with an IF statement?
> >
> > To me it seems silly to invent multiple variations of IF's
> > to improve readability by 5%.
>
> So you admit that the perl model is more readable, and therefore more
> maintainable.
>
> Now go away.
>
In my opinion it is not. I was giving you the benefit of a doubt
by considering that in some eyes it might be a little more
readable if used often.
But given the more civilized options I presented, 5% credit is not
enough to justify juryrigged IF's.
Spend confusion and complexity wisely, not frivilously.
> --
> Jerome O'Neil, Operations and Information Services
> Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
> jeromeo@atrieva.com - Voice:206/749-2947
> The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
>
-tmind-
http://www.geocities.com/SiliconValley/Lab/6888/langopts.htm
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 28 Jan 1999 20:19:40 GMT
From: sprintfer@yahoo.com (Mike D.)
Subject: perl DBI CGI and mySQL
Message-Id: <36b0c61b.280418630@nntp.cts.com>
I am experimenting with mySQL and the DBI and CGI modules. I have a
small customer table with idnumber, fname, lname, email, password,
etc.
I now can do a simple query via the web to lookup a row.
I am wonder if I append a row to the table via the web, do I need to
lock the table (let's assume there are many people using the datbase
at the same time) - or is the table locked/secure automatically?
Also, I was wondering if anyone has any example scripts I can take a
look at that uses mySQL DBI and the CGI module? (like the source of
register.cgi at www.pm.org/source/registration)
I appreciate your help.
Mike D.
sprintfer@yahoo.com
------------------------------
Date: 28 Jan 1999 14:40:49 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl's malloc [Gosh, s// faster than m//]
Message-Id: <78psth$40s$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jonathan Feinberg
<jdf@pobox.com>],
who wrote in article <m3ww2813to.fsf@joshua.panix.com>:
> > > match_1: 13 wallclock secs (13.39 usr + 0.01 sys = 13.40 CPU)
> > > match_2: 10 wallclock secs ( 9.89 usr + 0.00 sys = 9.89 CPU)
> > > substitute: 6 wallclock secs ( 7.10 usr + 0.00 sys = 7.10 CPU)
> Well, I recompiled with perl's malloc, and lo!
>
> Benchmark: timing 200000 iterations of match_1, match_2, substitute...
> match_1: 11 wallclock secs (10.12 usr + 0.00 sys = 10.12 CPU)
> match_2: 8 wallclock secs ( 8.98 usr + 0.00 sys = 8.98 CPU)
> substitute: 8 wallclock secs ( 6.71 usr + 0.00 sys = 6.71 CPU)
>
> Why is the perl malloc feature a default [n] in the config script?
Somebody need to check that it better than the system one (including
size considerations, see ps and/or /usr/proc/bin/pmap), and supply a
patch for hints files.
There are a couple of systems where compiling with mymalloc leads to
problems. If these are taken into account, then the default may be
changed to `y'.
Ilya
------------------------------
Date: Thu, 28 Jan 1999 14:03:57 -0700
From: "gip" <gibsonc@aztec.asu.edu>
Subject: Problems with Win32 perl and odbc.pm
Message-Id: <78qj2g$kom@bmw.hwcae.az.Honeywell.COM>
I have a weird problem, using ActiveState's latest build, 509, and Roth's
ODBC.PM. I've got the PRK with SP1.
When I run with the debugger, my SQL commands return the correct values.
When I run without the debugger, my SQL commands return the hashed values
instead.
Any ideas?
------------------------------
Date: 28 Jan 1999 22:26:40 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Reading headers & LWP
Message-Id: <83k8y7rsvj.fsf@vcpc.univie.ac.at>
Re: Reading headers & LWP, Bill
<moseley@best.com> said:
Bill> Thanks. I did read that but it didn't sink in
Bill> what it mean -- I haven't written a sub-class
Bill> before. Thanks very much for the example!
>> sub redirect_ok { 0; }
[please attribute my reply! - thanks]
One thing that occurred to me after posting my reply
with the subclassing is how to predicate the
redirection based on the request type (e.g. by
method). You could extend the redirect_ok override
thusly:
sub redirect_ok {
my ($self, $req) = @_;
my $m = $req->method;
($m eq 'GET' || $m eq 'HEAD') ? 0 : 1;
}
i.e. no redirect if we GET or HEAD, but POST will
auto-redirect. ($self is this agent, $req is the
HTTP::Request object). A look at the source code
for LWP::UserAgent is rather instructive.
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Thu, 28 Jan 1999 21:07:19 GMT
From: jimmy <jimmy@globalSpam.org>
Subject: regex lib or Perl linked in?
Message-Id: <36B0CFD1.57F37BA0@globalSpam.org>
What's a good way to add Perl's functionality to a C++ program: to link
Perl in, or use a standalone regex library? If the latter, where would I
get one? Anything freely available?
Thanks
Len
(personal replies can be sent to seven three six six two dot two six
five one at compuserve dot com)
------------------------------
Date: Thu, 28 Jan 1999 16:00:49 -0500
From: Denis Haskin <Denis.Haskin@bigfoot.com>
To: Steve Jackson <steve@NOSPAMcyber-distributors.com>
Subject: Re: Sorting a file in Perl question :: please help :)
Message-Id: <36B0D001.7CFCF1DD@bigfoot.com>
See this, it should help:
ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/doc/FMTEYEWTK/sort.html
(you don't have to get it from iguide; any CPAN site should do).
Also maybe look at
http://language.perl.com/newdocs/pod/perlfaq4.html#How_do_I_sort_an_array_by_anyth
I think between those 2 docs you should be able to find a good solution.
It's a common stumbling place.
dwh
Steve Jackson wrote:
> Ok I have a file called "seven.txt". Inside that file is pratically a
> [...etc...]
> BAsically I need the whole file read and then
> sorted
> alphabetically by the second field [...etc...]
------------------------------
Date: Thu, 28 Jan 1999 21:22:44 GMT
From: Ryan.Haman@mci.com
Subject: Stopping a foreach loop
Message-Id: <78qkep$uqm$1@nnrp1.dejanews.com>
Is there anyway to break (stop) a foreach loop?
Thanks in Advance
Ryan Haman
Ryan.Haman@mci.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 28 Jan 1999 21:12:22 GMT
From: thegroovy@aol.comNOSPAM (THE Groovy)
Subject: Visual Perl?
Message-Id: <19990128161222.15686.00003829@ng20.aol.com>
Maybe this is old news, but I just read a couple days ago that Activestate was
attempting to create a "Visual Perl", to compensate for one of Perl's major
weak points - No Visual Interface. What would this mean for Perl developers?
Could Perl possibly become a major Windows programming language like VB? Or
would it be to slow because of the need to compile, etc? Also, does anyone
think that MS might add the Perl compiler into IE, allowing Perlscript to be
viewed by everyone with upgraded browsers?
Send me your thoughts on all of this..
Regards,
Gil Hildebrand, Jr.
UIN: 28517138
THEGroovy\@aol.com
remove the \ to email me (I hate spam!)
------------------------------
Date: Thu, 28 Jan 1999 19:24:09 GMT
From: Denis.Haskin@bigfoot.com
Subject: WinNT Perl 5.005-02: Changed behavior of `dir` after Cygwin B20 installed
Message-Id: <78qdge$o8h$1@nnrp1.dejanews.com>
[Q also posted to gnu-win32@cygnus.com but there's enouigh discussion of
similar problems here, so...]
[I've checked the FAQ(s) and mailing list archives but can find no explanation
for this, so...]
I am on Windows NT 4.0, SP3. I have Perl 5.005-02 on here (the MSWin32
version, I compiled it here myself with Visual C) and everything has been
hunky-dory (okay, mostly).
I installed Cygwin B20 yesterday, since some of the things I need to do will
be greatly eased by having some of the common Unix utilities.
I am very perplexed as to why the behavior of the dir command, when executed
in a subprocess (backticks) from Perl, has changed.
Yesterday, before installing Cygwin, when I ran the following perl script:
$ret = `dir`; $ret contained the results of a DIR command as the NT command
processor executes it.
Now when I run that (after Cygwin installed), the same command results in $ret
getting the results of (sort of) Cygwin's ls command.
I am starting Perl from an NT command prompt, not from bash. PERL5SHELL
environment var is not set.
Is there a switch or something that controls this? I tried getting rid of
MAKE_MODE=UNIX (even though that should not have affected this).
I've also tried messing with the PERL5SHELL environment var, to no avail.
Can anyone provide any assistance?
Thanks very much,
dwh
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 28 Jan 1999 21:25:52 GMT
From: "Quentin Compson" <bcompson@yahoo.com>
Subject: Writing my own Email script but not getting it.
Message-Id: <01be4b04$7142ace0$0d20440c@brmptrue>
Hi
I'm trying learn how to write a simple script to send the results
of a cgi form.
It is send the subject line but ignoring the body.
Can anyone tell me what I am doing wrong.
#!/usr/bin/perl
$mailprog= "/usr/sbin/sendmail" ;
$recipient= "bcompson\@yahoo.com";
open(MAIL, "|$mailprog $recipient")
|| &HTMLdie("Couldn't send the mail (couldn't run $mailprog).") ;
$ENV{'HTTP_REFERER'} || ($ENV{'HTTP_REFERER'}= "SLC") ;
print MAIL "Subject: Form data from the Web\n\n",
"The following data was entered at $ENV{'HTTP_REFERER'}:\n\n" ;
read(STDIN, $in, $ENV{'CONTENT_LENGTH'}) ;
@elements = split(/&/, $in);
foreach $element (@elements) {
$element =~ tr/+/ /;
($name, $value)= split("=", $element) ;
$name =~ s/%([\dA-Fa-f][\dA-Fa-f])/ pack ("C", hex($1))/eg;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/ pack ("C", hex($1))/eg;
print MAIL "$name = $value",
}
close(MAIL) ;
print <<EOF ;
Content-type: text/html
<html>
<body>
<h3>Your data has been sent.</h3>
</body>
</html>
EOF
http://revdwj.virtualave.net/suggest3.html
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4772
**************************************