[15586] in Perl-Users-Digest
Perl-Users Digest, Issue: 2999 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 10 00:05:25 2000
Date: Tue, 9 May 2000 21:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957931508-v9-i2999@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 9 May 2000 Volume: 9 Number: 2999
Today's topics:
Re: #How to parse and strip perl comments? <phill@modulus.com.au>
Re: 1xPERL PROGRMMER NEEDED... <asackett@artsackett.com>
Re: 1xPERL PROGRMMER NEEDED... <pagesusa@hotmail.com>
Re: BEGIN and use (Tad McClellan)
Can a informix database manipulated by perl programming <joydip_chaklader@my-deja.com>
Re: File Upload Script <joydip_chaklader@my-deja.com>
Gotta be in the FAQ...but it doesn't seem to be... (Eric Dew)
Re: Help Needed - Perl Matching Operator <shell@hkscript.com>
Re: if file already exists then remove... (Abigail)
Re: if file already exists then remove... (Abigail)
Re: Is Perl fast enough? <jeff@vpservices.com>
Re: Is Perl fast enough? pohanl@my-deja.com
Re: Keys of Hash (Abigail)
Re: Mail::Mailer not setting from? <john@ieffects.com>
Re: Need help on displaying REMOTE_HOST <joydip_chaklader@my-deja.com>
Need some help with database function added to ntformma mcompservices@my-deja.com
Re: Perl 5.6 stable?? kraehe@copyleft.de
Perl Modules Internals Class on May 25 (Mark-Jason Dominus)
Re: Quality of perl implementations (Ilya Zakharevich)
Re: Strange Characters from Perl Script <godzilla@stomp.stomp.tokyo>
Re: Strange Characters from Perl Script <godzilla@stomp.stomp.tokyo>
Re: tricking the regex syntax (Abigail)
Uploading large files with LWP <billhess2000@home.com>
Writing to serial port on UNIX systems <cklatsky@home.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 May 2000 12:48:27 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: #How to parse and strip perl comments?
Message-Id: <3918CDFB.3B6B@modulus.com.au>
Brad Baxter wrote:
>
> On Tue, 9 May 2000, Peter Hill wrote:
>
> > Abigail wrote:
> > > That begs the question, why can't production code have comments?
> > >
> > > Abigail
> > No reason, indeed. But nor does it beg the question. I want to strip the
> > existing comments which are excessive,
> > inappropriate and in some cases just plain wrong, since they were
> > written at the level of "the next line does 'blah'". I'll then replace
> > them with appropriate notes for any particular choices which may not be
> > self evident from the code, which would seem to be better commenting
> > practice than writing pseudo-code which *may* or *may not* reflect what
> > the following code actually does in perl.
> >
> > But, I'm learning as I go; any comments on comments or commenting style
> > appreciated.
>
> Sounds like a manual job anyway, since you have to make a judgement call.
>
> --
> Brad
Which is how I wound up doing it.
I still find it curious that with perl you can create a (non-trivial)
regex to strip out C - type comments, but it seems difficult at least to
do the same for perl's own comments. As mentioned by Tom Phoenix,
Deparse comes close.
--
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/
------------------------------
Date: 9 May 2000 21:18:32 -0600
From: Art Sackett <asackett@artsackett.com>
Subject: Re: 1xPERL PROGRMMER NEEDED...
Message-Id: <3918d508@209.94.64.50>
On Tue, 09 May 2000 19:33:52 GMT in alt.html AztecOne / Chris
<pagesusa@hotmail.com> honored us all with these words:
AC:
AC: You seem to assume our prices are unreasonable. Our prices are not
AC: unreasonable.
Speak for yourself. My prices are very much unreasonable.
---- Art Sackett ----
Art Sackett Professional Web Design
1067 Cleveland Street
Meeker, CO 81641-3217
USA
+1.970.878.5014
http://www.artsackett.com
------------------------------
Date: Wed, 10 May 2000 03:35:57 GMT
From: "AztecOne / Chris" <pagesusa@hotmail.com>
Subject: Re: 1xPERL PROGRMMER NEEDED...
Message-Id: <xO4S4.5271$P55.21600@typhoon.tampabay.rr.com>
Art Sackett wrote in message <3918d508@209.94.64.50>...
>On Tue, 09 May 2000 19:33:52 GMT in alt.html AztecOne / Chris
><pagesusa@hotmail.com> honored us all with these words:
>AC:
>AC: You seem to assume our prices are unreasonable. Our prices are not
>AC: unreasonable.
>
>Speak for yourself. My prices are very much unreasonable.
>
Hey the way I see it, they pay for our knowledge. None of us would be in
business if our prices were unreasonable.
This person does not want to pay for our knowledge and our time spent
learning. They want us to do it for them because maybe one day they might
throw some business our way.
Yippee
Chris
------------------------------
Date: Tue, 9 May 2000 18:25:05 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: BEGIN and use
Message-Id: <slrn8hh421.h12.tadmc@magna.metronet.com>
On Tue, 9 May 2000 13:37:01 -0400, Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
>On Tue, 9 May 2000, Larry Rosler wrote:
>> {
>> STATEMENT;
>> STATEMENT;
>> }
>>
>> realize that there are *three* statements in the body of the block.
>> (Operationally, it doesn't matter, of course.)
>
>Given the idea that in a string there is a null string at the
>beginning, between each character, and at the end, why wouldn't there be
>five statements in the body of the block?
Because semicolons separate the statements.
You would need 4 semicolons to separate 5 statements,
but there are only 2.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 10 May 2000 01:59:23 GMT
From: Joydip Chakladar <joydip_chaklader@my-deja.com>
Subject: Can a informix database manipulated by perl programming
Message-Id: <8fafpk$kkp$1@nnrp1.deja.com>
Does perl have the neccesary subroutines to manipulate informix
database Version 6.0 (Unix version) and provide functions such as add
record modify record delete record and different operation on database
which will be ported on web
Can anybody help me on the total operation - how it would be.
Thanks in advance
--
Joydip Chakladar
http://www.allindialive.com
From India to world
A meeting place of surfers and webmasters
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 10 May 2000 02:16:05 GMT
From: Joydip Chakladar <joydip_chaklader@my-deja.com>
Subject: Re: File Upload Script
Message-Id: <8fagoq$lrv$1@nnrp1.deja.com>
Try this script . May help you.
use CGI;
$onnum = 1;
while ($onnum != 11) {
my $req = new CGI;
my $file = $req->param("FILE$onnum");
if ($file ne "") {
my $fileName = $file;
$fileName =~ s!^.*(\\|\/)!!;
$newmain = $fileName;
if ($allowall ne "yes") {
if (lc(substr($newmain,length($newmain) -4,4))
ne $theext){
$filenotgood = "yes";
}
}
if ($filenotgood ne "yes") {
open (OUTFILE, ">$basedir/$fileName");
while (my $bytesread = read($file, my $buffer,
1024)) {
print OUTFILE $buffer;
}
close (OUTFILE);
}
}
$onnum++;
}
print "Location: $donepage\n\n";
--
Joydip Chakladar
http://www.allindialive.com
From India to world
A meeting place of surfers and webmasters
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 10 May 2000 01:28:26 GMT
From: edew@netcom.com (Eric Dew)
Subject: Gotta be in the FAQ...but it doesn't seem to be...
Message-Id: <8fadvq$n7j$1@slb0.atl.mindspring.net>
I looked at the FAQ. The closest to my question is the one in section 3
(perlfaq3):
How can I get '#!perl' to work on [MSDOS,NT,...]?
My question is almost the same. I want to create a script which can be
used on different systems. On each system, perl is located in different
places. For example, on the unix system, it's located in the usual
/usr/local/bin/perl location. So my first line in a script would be:
#!/usr/local/bin/perl
On the NT (through running cygwin), it's located in //d/usr/local/bin. Thus
my first line is:
#!//d/usr/local/bin/perl
One way to deal with this is to use the //d/usr/local/bin/perl directory
path and create a symlink /d -> / on the unix side.
However, we have many unix machines, and many new machines keeps popping up.
I don't want to have to go onto each unix machine and add a symlink,
cd /
ln -s / d
to each one.
Is there a way to provide additional paths on the #!/... line?
Thanks,
EDEW
------------------------------
Date: Wed, 10 May 2000 10:24:19 +0800
From: Shell Hung <shell@hkscript.com>
Subject: Re: Help Needed - Perl Matching Operator
Message-Id: <3918C853.9EE5B2CA@hkscript.com>
There're no different of m/// and s///, for example, if you want remove
all "@" inside the email address, you can use s/// | m///,
$Email = "abc\@abc.com";
$Email =~ s/\@//;
Now, $Email = "abcabc.com";
Kelvin wrote:
> I'm little confusing of how to use the matching operator in perl!
> I'm writing a function to check if the user enter a valid email address,
> but I don't sure how to use the m// operator.
>
> sub checkemail {
> $_ = $enteredEmail;
> m/"@"//;
> }
$CheckCode = &checkemail($EmailAddressWantToCheck);
&error("Not valid") if (!$CheckCode)
sub checkemail {
$_[0] =~ /\@/;
return('Found') if ($1);
}
>
> is that correct?
> Or how can I make sure the $enteredEmail included a "@" in it?
Why don't you use another regex to check the valid email address ?
--
*********************************************
Shell Hung - [Life - Control by yourself]
(SW E-Solutions) Analyst Programmer
(http://www.hkscript.com) Technical Director
Email : shell@hkscript.com (hkscript.com)
PGP Key : 0xC268210F (DH/DSS-1024)
*********************************************
------------------------------
Date: 10 May 2000 01:25:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: if file already exists then remove...
Message-Id: <slrn8hhekf.ndt.abigail@ucan.foad.org>
On 4 May 2000 08:50:49 GMT,
Villy Kruse <vek@pharmnl.ohout.pharmapartners.nl> wrote:
++ On Wed, 03 May 2000 18:45:41 GMT, Bart Lateur <bart.lateur@skynet.be> wrote:
++
++ >
++ >But actually, unlink doesn't mind a failure, so simply drop the test.
++ >
++ > unlink $filename;
++ >
++
++
++
++ Unless you need to know if the unlink failed for reasons other than the
++ filename did not exists.
unlink $filename or $! == 2 or die $!;
Abigail
------------------------------
Date: 10 May 2000 01:42:14 GMT
From: abigail@foad.org (Abigail)
Subject: Re: if file already exists then remove...
Message-Id: <slrn8hhfjm.ndt.abigail@ucan.foad.org>
On Thu, 04 May 2000 00:26:02 GMT, Craig Berry <cberry@cinenet.net> wrote:
++
++ When you go to unlink a file, there are three possible outcomes, and a
++ reasonable program might wish to deal differently with each:
++
++ 1) The target file doesn't exist, so can't be deleted.
++ 2) The target file exists, but can't be deleted for other reasons.
++ 3) The target file is deleted.
++
++ Doing -e conditionally followed by an error-checking unlink is the
++ simplest way to discriminate between the three cases.
++
++ Merely doing an error check on unlink makes it hard to discriminate
++ between cases 1 and 2. As a result, it is difficult to determine if the
++ file does or does not exist following the unlink.
I disagree. Doing a -e followed by an unlink isn't an atomic action.
What if some other process deletes the file after you did the -e,
but before you did the unlink? But checking the return value of
unlink, and if false, the value of $!, makes it trivial to distinguish
between 1), 2) and 3). And since -e followed by unlink isn't atomic,
you need to do that anyway, so why bother with the -e?
Abigail
------------------------------
Date: Tue, 09 May 2000 18:16:18 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Is Perl fast enough?
Message-Id: <3918B862.3BB85505@vpservices.com>
Eric Bohlman wrote:
>
> Jeff Zucker (jeff@vpservices.com) wrote:
> : out of that setup. It's not the total number of lines that matters,
> : it's the total number you try to deal with simultaneously at any one
> ^^^^^^^^^^^^^^^^^^^^^^^^^
> : point in time. Forgive me if I'm pointing out the obvious.
> ^^^^^^^^^^^^^
> Are you certain that that figure completely swamps out the impact of
> things that you try to deal with simultaneously at different points in
> time? Perhaps the Department of Redundancy Department has done some
> computations?
Eric, Eric, Eric, you are out of date, my man. This whole issue of
simultaneity at different points in time is covered in several different
module hierarchies. Get the Wells::Time::Machine, Bradbury::Butterfly,
or Jung::Synchronicity modules. If you thought race conditions were a
problem before, you ain't seen nothin yet.
--
Jeff
------------------------------
Date: Wed, 10 May 2000 02:20:31 GMT
From: pohanl@my-deja.com
Subject: Re: Is Perl fast enough?
Message-Id: <8fah13$lum$1@nnrp1.deja.com>
To answer your question, yes, the program is
tied to a database, and is accessable through
a memory based key search. Whas is XS module?
XSL? Or is this some sore of C module that
is tuned to deal with keys?
By the way, can you check it out and tell
me what you think?
http://www.edepot.com/religion.html
Post a message with the word eglossary
and it should be automaticaly linked to
the perl program.
In article <Pine.GSO.4.10.10005090407250.3921-
100000@user2.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:
> On Tue, 9 May 2000 pohanl@my-deja.com wrote:
>
> > Subject: Is Perl fast enough?
>
> Probably. :-)
>
> > Perl is a scripting language that basically has an interpreter
> > that goes through the code and follows the script.
>
> I humbly disagree. Your description in the next sentence is much more
> accurate:
>
> > It is my understanding that there is a compilation stage where the
> > script is compiled into something that resembles bytecodes in java,
> > and the interpreter will then run the bytecode (am I correct on
this?)
>
> Sounds good to me.
>
> > Bytecodes contain instructions for a virtual machine cpu (like Load
> > and Store operations in assembly).
>
> Not really. At least, not really in my opinion, when it comes to
Perl. As
> far as I know. In the current version. Subject to modification without
> notice. All rights reserver. Do not taunt Happy Fun Perl.
>
> > I know in Java the Virtual machines is supposed to run a garbage
> > collector in the background (or when idle) to reclaim memory used by
> > unreferenced variables. Early versions of the VM simply allocated
> > memory and didn't even bother to garbage collect (the code for it
> > wasn't even in there!) I think the latest versions have some sort
of
> > garbage collection built in.
>
> Okay....
>
> > Does perl have garbage collection? When is it run? Or if there
> > even is a garbage collector? If it does exist, when does
unreferenced
> > variables get garbage collected? Right when they are not
referenced?
> > Or does a background garbage collection comes around and frees up
> > memory when memory is low, or when it is idle, or checks
periodically
> > now and then, or runs constantly in the background (don't know if
> > this is possible if multi-threads are not supported on some
platforms).
>
> Have you seen the perlobj manpage? It has a section called "Two-Phased
> Garbage Collection" which may answer all of your questions. Then
again,
> maybe not - you have quite a few. :-)
>
> > But anyhow, because it is a dictionary type of perl program, it
> > uses a lot of memory and it does a lot of comparisons (it will
> > need speed). So I am guessing there is an upperlimit number
> > of glossary terms that it can handle before Perl cannot be used
> > anymore. (In this case needing a c/c++ replacement).
>
> I wonder whether you should be using some sort of tied data structure
> which would let you keep more data in memory efficiently. In general,
when
> you need a "very large" data structure, especially one with
homogeneous
> data (such as an array of 10e10 two-byte integers, say), it's often a
good
> idea to use a tied array or hash. See the perltie manpage.
>
> Or, maybe you should keep your data on disk and only have some sort of
> index in memory. This solution may take the most "brain sweat" to
create,
> but it could be the fastest way in the end. Then again, you could
spend a
> year thinking about it and never find a solution. That's life!
>
> Or, maybe you could put the key code into an XS-based module. That
can let
> you get a big speed advantage for the things that C can do quickly
while
> still using Perl for what Perl can do quickly (such as, cut down your
time
> at the keyboard).
>
> > Has anyone ever created a memory intensive and speed sensitive
> > application in perl?
>
> One or two. :-)
>
> > Can you comment on this? Has anyone ever written a perl program
that
> > crashed because of some upper bound in speed or memory requirement?
>
> Once or twice. :-)
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 10 May 2000 01:52:25 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Keys of Hash
Message-Id: <slrn8hhg6p.nq7.abigail@ucan.foad.org>
On Wed, 03 May 2000 09:39:12 -0700,
Samay <samay1NOsaSPAM@hotmail.com.invalid> wrote:
++ >
++ >Samay> How I can get it??
++ >
++ >for my $first (sort keys %X) {
++ > for my $second (sort keys %{$X{$first}}) {
++ > "you now have $first and $second - enjoy!";
++ > }
++ >}
++ >
++ >print "Just another Perl hacker,"
++
++ Thank you for the answer.
++ However your answer uses 2 for loops and a sort etc..
++ Which makes O(N*N) algorithm.
No, it doesn't. It's not looping over the same sets. Due to the sorting,
the program is O (N log N). If you drop the sort()s, it's O (N).
++ I actually want this in tirms of O(N).
++ Is it possible??
Yes. Forget about sorting it.
Abigail
------------------------------
Date: Tue, 9 May 2000 20:41:02 -0600
From: "John Keiser" <john@ieffects.com>
Subject: Re: Mail::Mailer not setting from?
Message-Id: <i04S4.1$Tk1.1046@news.uswest.net>
Tom Phoenix <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.10.10005081930560.3921-100000@user2.teleport.com...
> On Mon, 8 May 2000, John Keiser wrote:
>
> > No matter what, the From field in the email is set to my unix account.
>
> It sounds as if whatever method Mail::Mailer uses on your system isn't
> configured to let you set that header. Maybe you won't be able to use
> Mail::Mailer, or maybe you'll have to tell it to use a different method.
> See the Mail::Mailer docs to find out how to choose a different method.
>
Thanks, I set it to sendmail and it works now. Also found the problem with
the current method: it's using the Mail method and /etc/mail.rc is set up to
ignore Mail-From.
--John
------------------------------
Date: Wed, 10 May 2000 01:52:55 GMT
From: Joydip Chakladar <joydip_chaklader@my-deja.com>
Subject: Re: Need help on displaying REMOTE_HOST
Message-Id: <8fafdh$k3g$1@nnrp1.deja.com>
> Adapted from 'perldoc -f gethostbyname', the following would fill in
> REMOTE_HOST with the name, if it resolves, or REMOTE_ADDR if that
fails.
> Just put this somewhere in your script before you need it.
>
> use Socket;
> unless ($ENV{REMOTE_HOST} && $ENV{REMOTE_HOST} ne $ENV{REMOTE_ADDR}) {
> my $ipaddr = $ENV{REMOTE_ADDR};
> $ENV{REMOTE_HOST} = gethostbyaddr(inet_aton($ipaddr), AF_INET);
> $ENV{REMOTE_HOST} = $ENV{REMOTE_ADDR} unless $ENV{REMOTE_HOST};
> }
> --
> David Efflandt efflandt@xnet.com http://www.de-srv.com/
> http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
> http://hammer.prohosting.com/~cgi-wiz/
http://cgi-help.virtualave.net/
>
Thank you David it really worked great.
--
Joydip Chakladar
http://www.allindialive.com
From India to world
A meeting place of surfers and webmasters
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 10 May 2000 02:13:40 GMT
From: mcompservices@my-deja.com
Subject: Need some help with database function added to ntformmail
Message-Id: <8fagka$lc8$1@nnrp1.deja.com>
I have taken some code from YForm.cgi. This code
was the appending to database feature. I included
all necessary varaibles and functions. I created
the formres.dat on the server and updated my html
to set all variables for the database. I added
this code to my ntformail.pl script. When I fill
out the form everything runs smoothly but then
when I go to download the .dat file to see the
results, its still empty. Could this be because I
might not have write permission to the direc and
file? Wouldn't i get an error if I didn't. If you
want I will send the script. Appreciate it all.
Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 10 May 2000 04:02:21 GMT
From: kraehe@copyleft.de
Subject: Re: Perl 5.6 stable??
Message-Id: <8fan0d$s22$2@news.bnhof.de>
bryan@nospam.panix.com wrote:
> I known this is considered a stable and Production release, but since I don't
> known when it was released - is a 5.6.1 coming anytime soon? I have a feeling
> the answer will be go with 5.6.
I've tested Perl 5.6 as /opt/perl-5.6 on a Debian/Woody, and imho Perl 5.6
is not so stable as it should be. While it was possible to build the
Bundle::CPAN, several modules within the Bundle::XML are broken by the
new perl, and two of them even cause Perl to dump core ;-(
XML::Encoding
Segmentation fault (core dumped)
#0 0x401c4093 in doContent ()
from /opt/perl-5.6.0/lib/site_perl/5.6.0/i686-linux/auto/XML/Parser/Expat/Expat.so
XML::Writer
Attempt to free unreferenced scalar at test.pl line 513.
Segmentation fault (core dumped)
#0 0x400e754f in memcpy () from /lib/libc.so.6
#1 0x8099613 in Perl_pp_entersub ()
#2 0x8093fc0 in Perl_runops_standard ()
#3 0x805bedc in S_run_body ()
#4 0x805bc7b in perl_run ()
#5 0x80598c0 in main ()
#6 0x400aaa42 in __libc_start_main () from /lib/libc.so.6
So I hope for a is coming Perl 5.6 real soon ;-)
Bye Michael
--
mailto:kraehe@bakunin.north.de UNA:+.? 'CED+2+:::Linux:1.2:13'UNZ+1'
http://www.xml-edifact.org/ CETERUM CENSEO MSDOS ESSE DELENDAM
------------------------------
Date: Wed, 10 May 2000 01:02:13 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Perl Modules Internals Class on May 25
Message-Id: <3918b514.bf8$99@news.op.net>
Keywords: cerebellum, chateau, correspondent, mackintosh
Later this month, and also on the Perl Whirl cruise in June, I'll be
giving a three-hour class called `Internals of Perl Core Modules' I
want to get some advance practice, so I'll have a practice session in
West Philadelphia. I'd be delighted if you'd come. I am charging $5
admission to cover expenses, and I will donate any extra money to the
Free Software Foundation.
The tutorial will be at the University of Pennsylvania Center for
Literacy at 3910 Chestnut Street in Philadelphia. It will begin at
6:00 and end around 9:30 or 10:00 PM.
Reservations are required. To make a reservation, please send email to:
mjd-perl-practice+@plover.com
Some information about the course content is available at:
http://old.plover.com/~mjd/perl/TPC/2000/Internals/
I will update this page when I know more about it.
Also please feel free to circulate this notice to any person or
organization that you think might be interested. Please don't
circulate it after May 25.
The class is made possible through the kindness of The Penn Center for
Literacy and the Philadelphia Perl Mongers (http://phl.pm.org).
(Note that this message was posted with `Distribution: phl' in the
header. If you are not in Philadelphia, and you received it anyway,
it is because your news administrator made a decision to carry
articles that are specifically marked as only of interest to people in
Philadelphia. If you don't like this, complain to your news provider,
not to me.)
------------------------------
Date: 10 May 2000 00:24:43 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Quality of perl implementations
Message-Id: <8faa8b$65i$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Mike Heins
<nobody@internetrobotics.com>],
who wrote in article <8f5en002fl8@news1.newsguy.com>:
> I will labor along under my delusions, if you don't mind.
No, I do not. I would not even mind people writing applications in
TCL, DOS batch files etc.
> I have managed to produce a program that is fairly large, is in
> fairly wide use, and is entirely (or almost) in Perl.
Which still does not make Perl a programming language.
> 2. You can't use signals in Perl.
>
> On BSD and derivatives, I agree. On Solaris and Linux and other
> SYS5-ish OS, Perl seems to do pretty well. Failure rates
> on busy systems that are not that much different than the rate
> of parity errors in RAM of a few years ago.
In my experiments every 30th signal corrupts perl process (so that the
corruption is easily detectable, actual corruption can happen more
often). But still feel free to "labor along under your delusions".
> Had I listened to the unoffical information, I might not have
> done it. And it works just fine in the real world.
The criterion "works just fine in the real world" is the latmus test
for scripting.
Ilya
------------------------------
Date: Tue, 09 May 2000 18:59:27 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Strange Characters from Perl Script
Message-Id: <3918C27F.A21D31E0@stomp.stomp.tokyo>
David Guiney wrote:
(snipped, context retained)
> I have written a perl cgi script on a unix server
> left and right brackets are returned as %28 and %29.
> If you want to test this you can use the web page:
> www.celticmarketing.com/testform.html
> This calls the following script:
> Any help would be much appreciated.
Hi David,
You have some syntax problems with your
script. I tested your script at your
site and received expected results as
you delineated. Your primary problems
lie in your read and parse routine.
Rather than exemplify those problems,
I have written a simple test script
for you to examine, compare and for
you to play with. This is only a
simple test script to exemplify
basic methods you need to accomplish
your stated goal within the context
of your article.
Please compare this script carefully
with your original script and, you
will note some differences, especially
in the read and parse routine.
This simple test script affords no
more security than your original
version. You will need to address
basic security concerns which are
quite easy if you read and learn
about basic security issues.
http://www.eekim.com/pubs/cgibook/ch09/0902.html
This is a good beginning point for addressing
security issues. There are several pages at
this site, study all very carefully then move
into more advanced techniques in security.
Using this "Steve Brenner" style read and parse
I have in my script, can be modified to address
any and all security issues quite readily and,
other security issues not related to your read
and parse, can be 'accessorized' into your script.
This line:
$value =~ s/<([^>]+)>//gi;
...will kill almost all html tags. There
are some lame brain tricks to get around
this but none all that serious if you
address 'double up brackets' such as:
<"< html tag >">
...and similar. My choice is to deal with
people who pull these tricks in rather
harsh and imaginative ways. You may wish
to simply kill those kinds of tricks. My
more harsh choice in based on this type
of trick being one of malice intent. An
eye-for-an-eye, yes?
I left out your check for duplicate
variable names. Easiest cure for this
is to never use the same variable name
twice in a program unless you have a
very specific need for this. This is
quite rare.
An alternative to writing your own read
and parse, addressing your own security
needs, is to use cargo cult cgi.pm. This
is fine but will introduce a number of
problems for you. Stein's cgi.pm is a
nice module but has enough bugs and
quirks to question if it is worth use.
Another drawback is you can write your
own effective read and parse in roughly
twenty to thirty lines of code for around
one to two kilobytes of overhead. Use of
cgi.pm introduces a lot more this. Using
cargo cult cgi.pm introduces close to
six-thousand-five-hundred lines of code
and bloats your overhead to just short
of one-quarter of a megabyte, compared to
your homemade one to two kilobyte routine.
My suggestion is to work with this simple
test script I have written for you, read
and learn basic security issues well, then
give cgi.pm methodology a try. Test cgi.pm
well to learn of its bugs and limitations,
then decide which method works best for
you; homemade or cgi.pm. Which you use
is a matter of personal preference based
on your script's needs and your own needs.
This test script does not require an
html page like you have. It will print
your html page on its own. I have included
a bit of code as a 'control' for printing:
if (!($in{Field1})) # No Input Data
This only works for Field1 in your form
action, but serves well to exemplify how
you may control a print / no print. Your
form action will print for a new visitor.
It will print results after data input.
I have this read and parse routine setup
for a POST action. It will not work with
a GET action but is easy to modify if you
need to use GET for whatever reason.
I have tossed in a few of the most often used
environmental variables for you. Hopefully
these basic variables will work on your
internet service provider.
You will need to change the first line
to your Perl location and you may need
to change your path name for your script
to fit my form action print. You seem to
have more than enough skills to handle this.
My path is simply "test.cgi" but you may
need to plug in a full path name.
Again, this is a very basic, simple test
script to exemplify methods of concern
to you per your article. Do address basic
security concerns. Your original script
is not secure nor is this simple test script.
Godzilla!
Printed results first, test script last:
(your news reader may word wrap longer lines)
Printed Results:
________________
This Is Your Data Input:
Field 1: +First Field
Field 2: (2nd field)
These Are Some Environmental Variables:
Host Name: lats2-76.znet.net
IP Address: 207.167.96.76
User Agent: Mozilla/GODZILLA! GO GO GODZILLA!
Referrer: http://la.znet.com/~callgirl/test.cgi
[ Test Again ] (Form Action Return Button)
Test Script:
____________
#!/usr/local/bin/perl
print "Content-Type: text/html\n\n";
&Parse;
sub Parse
{ # Parse #
local (*in) = @_ if @_;
local ($i, $key, $value);
read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
@in = split(/&/,$in);
foreach $i (0 .. $#in)
{
$in[$i] =~ s/\+/ /g;
($key, $value) = split(/=/,$in[$i],2);
($value eq "") && next;
$key =~ s/%(..)/pack("c",hex($1))/ge;
$value =~ s/%(..)/pack("c",hex($1))/ge;
$value =~ s/<([^>]+)>//gi;
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $value;
}
return 1;
} # Parse #
if (!($in{Field1})) # No Input Data
{
print "
<FORM METHOD = \"POST\" ACTION = \"test.cgi\">
<INPUT TYPE = \"text\" NAME = \"Field1\" value = \"+First Field\">
<INPUT TYPE = \"text\" NAME = \"Field2\" value = \"(2nd field)\">
<INPUT TYPE = \"submit\" value = \"Press SUBMIT\">
</FORM>";
}
if ($in{Field1}) # Input Data
{
print "
This Is Your Data Input:<P>
<LI> Field 1: $in{Field1}<BR>
<LI> Field 2: $in{Field2}<P>
These Are Some Environmental Variables:<P>
<LI> Host Name: $ENV{REMOTE_HOST}<BR>
<LI> IP Address: $ENV{REMOTE_ADDR}<BR>
<LI> User Agent: $ENV{HTTP_USER_AGENT}<BR>
<LI> Referrer: $ENV{HTTP_REFERER}<P>
<FORM METHOD = \"POST\" ACTION = \"test.cgi\">
<INPUT TYPE = \"submit\" value = \"Test Again\">";
}
print "
</BODY></HTML>";
exit;
------------------------------
Date: Tue, 09 May 2000 19:37:48 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Strange Characters from Perl Script
Message-Id: <3918CB7C.32242B3F@stomp.stomp.tokyo>
"Godzilla!" wrote:
> David Guiney wrote:
David, I forgot to include a print
for your html header. Doesn't make
much of a difference. Would you add
this code as shown, right up top,
right after this line:
print "Content-Type: text/html\n\n";
Add this:
print "
<HTML><HEAD><TITLE>David Test</TITLE></HEAD><BODY>";
&Parse (reference so you will know where this fits in)
Sorry for forgetting to add this in.
I hope no problems resulted.
Godzilla!
------------------------------
Date: 10 May 2000 01:57:06 GMT
From: abigail@foad.org (Abigail)
Subject: Re: tricking the regex syntax
Message-Id: <slrn8hhgfi.nq7.abigail@ucan.foad.org>
On Wed, 3 May 2000 13:06:14 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
++
++ So one could use run-time selection between two regexes:
++
++ ($opt eq 'i' ? $line =~ /pattern/i : $line =~ /pattern/)
++
++ Decidedly uncool though. :-)
%pattern = (i => qr /pattern/i,
'' => qr /pattern/);
...
$line =~ /$pattern{$opt}/;
Abigail
------------------------------
Date: Wed, 10 May 2000 02:32:35 GMT
From: "Bill Hess" <billhess2000@home.com>
Subject: Uploading large files with LWP
Message-Id: <7T3S4.67759$h01.483995@news1.rdc1.mi.home.com>
I have been trying to upload large files (5 MB +) using LWP and am having
problems...
I am attempting to use LWP::UserAgent::request(POST, ...) and it appears
that the file is first loaded into memory on the client and then it is
pushed to the server - small files work fine
I have tried to use the DYNAMIC_FILE_UPLOAD variable with no Content-Length
specified and cannot seem to get this to work either. I am using Apache as
my web server and I read in the HTTP::Request::Common perldoc that some
servers require the Content-Length. Is Apache one of them?
Has anyone out there had success with DYNAMIC_FILE_UPLOAD?
Bill Hess
------------------------------
Date: Wed, 10 May 2000 01:13:57 GMT
From: Carl Klatsky <cklatsky@home.com>
Subject: Writing to serial port on UNIX systems
Message-Id: <3918B799.105E16E6@home.com>
Hi,
I am a beginner at writing PERL and I'm trying to read and write to the
serial port. I'm trying to develop a script that automates sending
commands to a router attached to my computer's serial port. The
commands to be sent are very similar, so this seems like a good job for
PERL. After reading the manpages perlfaq8 and perlipc, I still don't
have it sending the commands to the serial port right. As a first cut,
I modified code I saw in the perlipc man page and I have:
#! /usr/local/bin/perl
$a = "if-cfg 71 0 71 384 rfc1483 192.168.71.1 255.255.255.0"; ---1st
command to send to router
$b = "if-cfg 81 0 81 384 rfc1483 192.168.81.1 255.255.255.0"; ---2nd
command to send to router
use FileHandle;
use IPC::Open2;
$pid=open2(*Reader, *Writer, "cu -l /dev/cua0 -s 9600 --parity=none");
---using cu to open serial port to router
print Writer "$a\015"; ---writing 1st command, with linefeed value
$got=<Reader>; ---reading response from router
print STDOUT $got; ---printing response from router
print Writer "$b\015"; ---writing 2nd command, with linefeed value
$not=<Reader>; ---reading response from router
print STDOUT $not; ---printing response from router
print STDOUT "Made it here\n"; ---print to track flow of script
The output I get is:
bash-2.02# perl test5.pl
if-cfg 71 0 71 384 rfc1483 192.168.71.1 255.255.255.0
Made it here
bash-2.02# cu: End of file on terminal
cu: child: Got signal 13
bash-2.02#
Now what happened is the 1st command was sent, the echo if it (but not
the router's response) was captured in and printed, but it seemed to
hang on the 2nd write and print. Then the program exits. I don't know
why this is. I'm not hung up on this block of code. If someone know of
a different code fragment that will allow me to repeatedly send commands
out the serial port and read the responses, I would appreciate it.
Thanks,
Carl
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 2999
**************************************