[8823] in Perl-Users-Digest
Perl-Users Digest, Issue: 2439 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 28 11:07:22 1998
Date: Tue, 28 Apr 98 08:00:36 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 28 Apr 1998 Volume: 8 Number: 2439
Today's topics:
Re: 'each' and recursion, do they mix? (Mark-Jason Dominus)
Re: 'each' and recursion, do they mix? <tchrist@mox.perl.com>
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
Re: Anyone know how to cancel a Perl program? (Bart Lateur)
Re: Anyone know how to cancel a Perl program? (I R A Aggie)
Re: Binary Copy under Perl32 (Jeffrey R. Drumm)
Re: Cant call method prepare without package or object <fty@utk.edu>
Re: cgi-lib.pl or CGI.pm? (Bart Lateur)
Re: convert an @array into a single $variable? <jerryp.usenet@connected.demon.co.uk>
Defending Abigail (was: Defending Perl) (Chris Nandor)
Re: error opening Database file (Andrew M. Langmead)
help for beginer .. <steve.hardy@wipo.int>
Re: Help with regular expression <dorr@cetrel.lu>
Re: HELP! PerlScript <msergeant@ndirect.co.uk>
Re: How to add \ to an email address greene@gucc.org
Re: JavaScript to Perl var passing <quednauf@nortel.co.uk>
Mutliple emails <epnguy@sinfor.it>
Re: New boy on the perl block <jdporter@min.net>
Odd Regexp Question <dballing@speedchoice.com>
Passing a Javascript cookie to a Perl/CGI script <a.r.mccoy@larc.nasa.gov>
Re: Perl Scripts Newsgroup (Andrew M. Langmead)
Re: Perl/Wall lingo question <bmb@ginger.libs.uga.edu>
Re: Permutations in hashes make Perl hurt (Mark-Jason Dominus)
Re: Please stop and help. <chad@NOSPAMumr.edu>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Apr 1998 08:40:20 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <6i4ink$mlo$1@monet.op.net>
Keywords: fractious Grayson multiplication pug
In article <6i35ap$qtm$3@csnews.cs.colorado.edu>,
>You could put it on the C<each> syntax node.
Yes, but the problem with putting anything on the syntax node in Perl
is that each one is Yet Another Way in which perl subroutines are not
real closures. For example, if you wrote
sub itermaker {
return sub { each %hash };
}
my $i1 = itermaker();
my $i2 = itermaker();
&$i1; # Returns first k/v pair
&$i1; # Returns second k/v pair
&$i2; # Should return first k/v pair but returns third
Even though the objects returned by `itermaker' were supposedly
separate, and even though Perl would use tricks to keep their local
variables separate, they would share their `each'.
Languages like Lisp that have real closures wouldn't have this problem.
In Lisp you would write
(defun (itermaker)
(lambda () (each hash))
)
(setq i1 (itermaker))
(setq i2 (itermaker))
(i1) ; Returns first k/v pair
(i1) ; Returns second k/v pair
(i2) ; Returns first k/v pair since it has a separate iterator
------------------------------
Date: 28 Apr 1998 14:17:06 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <6i4od2$l8f$1@csnews.cs.colorado.edu>
Keywords: fractious Grayson multiplication pug
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, mjd@op.net (Mark-Jason Dominus) writes:
:Yes, but the problem with putting anything on the syntax node in Perl
:is that each one is Yet Another Way in which perl subroutines are not
:real closures.
You task, Dom Marco, should you choose to accept it, is to implement a
tied hash with its own multiple iterators.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Perl itself is usually pretty good about telling you what you shouldn't do. :-)
--Larry Wall in <11091@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Tue, 28 Apr 1998 10:24:02 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage893759041.26277@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 12 April 1998
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The Perl FAQ is modified frequently; the last major
update was in Spring of 1997. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://cpan.perl.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
403_662_481 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://cpan.perl.org/
http://www.perl.com/CPAN/
http://cpan.perl.org/doc/FAQs/FAQ/html/perlfaq.html
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq.html
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:
setdir usenet-by-group/news.announce.newusers
send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 28 Apr 1998 12:24:05 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Anyone know how to cancel a Perl program?
Message-Id: <3547ca2f.25248253@news.tornado.be>
Zisa wrote:
>I played with it and found that the Mac equivalent is
>control-option-c, in case any other Mac user needs this info.
Command-period works too.
HTH,
Bart.
------------------------------
Date: Tue, 28 Apr 1998 09:24:07 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Anyone know how to cancel a Perl program?
Message-Id: <fl_aggie-2804980924080001@aggie.coaps.fsu.edu>
In article <3545363A.1E24@juicepigs.com>, Bob Trieger
<sowmaster@juicepigs.com> wrote:
+ Zisa wrote:
+ > Is there a command or escape code for interrupting a running script?
+ ^C
+ or in windowspeak "Hold down the Ctrl key and press the letter c"
+ I don't know the MAC equivalent.
Command-. is the standard Mac way of interrupting.
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-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Tue, 28 Apr 1998 12:06:34 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Binary Copy under Perl32
Message-Id: <3545bacf.1437967@news.mmc.org>
[posted and mailed]
On Tue, 28 Apr 1998 02:30:58 GMT, aml@world.std.com (Andrew M. Langmead) wrote:
(snipped observations regarding Perl vs. system EOL handling)
>It depends on what you call "the system." I tend to think of the C
>library (where the setmode() function resides) as part of "the
>program", not part of "the system" but the Free Software Foundation,
>(and apparently Tom) seem to have a different view.
If it's the C library that's doing it, I can understand (but perhaps not
entirely agree with) Tom's point. Not being a C programmer, I wasn't aware that
the _library_ did this. I've worked with Pascal, so-called 4GLs, and various
flavors of BASIC (I know, that's where the bulk of the brain damage occurred),
and I'm pretty sure they don't exhibit this behavior. Mind you, I'm not saying
Perl is doing anything _wrong_, just that, in my experience, it's unexpected.
>This is the same manner in which every MS-DOS and Windows C compiler
>that I've seen works, except that C programmers tend to set the
>text/binary flag with the second argument to fopen().
My personal opinion is that fopen() should have text mode set for print and
write, but not for syswrite (I think of syswrite as more of a "dammit, write
what I meant, not what you think I meant" function). The binmode function would
continue to do as it does now, though, and alter the behavior of print and
write. But I'm sure that changinging this now would break a LOT of things . . .
>But you might be better of thinking of "\n" as a "newline," not a
>"linefeed." On systems where lines are terminated by linefeed
>characters, they may be interchangable, but don't expect it to carry
>to systems that terminate line differently. A newline is an abstract
>construct, a linefeed is a specific bit sequence that may be used to
>represent a newline.
I _have_ gotten into the habit of thinking of \n as 'newline', and representing
the line termination character(s) for whatever platform I'm on.
However, I think of chr(0x0A) as the line feed character, but Perl (or the C
library it's compiled with) apparently thinks it's \n . . . which on Windoze is
(chr(0x0D) . chr(0x0A)). In my mind, {print "some stuff",chr(0x0A)} and {print
"some stuff\n"} should _not_ produce equivalent results.
Of course, what _I_ think has been influenced heavily by past reliance on such
tools as BASIC . . . :-)
>>it could very well be Microsoft converting all those LFs to CRLFs
>>(but I doubt it).
>Well they do, but they do it in their C library, not in their
>operating system.
Point taken. Thanks for both the insight and for another reason to be happy I
get to spend most of my time on Unix. ;-)
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me
------------------------------
Date: Tue, 28 Apr 1998 09:11:26 -0400
From: Jay Flaherty <fty@utk.edu>
Subject: Re: Cant call method prepare without package or object reference
Message-Id: <3545D57D.4A94E802@utk.edu>
Keerman Gino wrote:
> I have a problem with the execution of a perl program that calls a perl
> module. as argumeents I give the database handle connection that is made
> in the program. When I use that parameter in the perl module the
> complains about Cant call method "prepare" without package or object
> reference.
Your connect method doesn't work. Are you checking for the errors? i.e:
#!/usr/bin/perl -w
use strict;
use DBI;
my $database = "test";
my $dbh = DBI->connect("DBI:mysql:$database", undef, undef)
or die "Unable to connect to $database: $DBI::errstr\n";
$dbh->disconnect;
exit;
__END__
You need to provide more information for better help. You can also help your
self by trying to debug your code (perl -d your_code.pl) and checking for
proper return values on object creation as demonstrated above...good
luck...jay
--
**********************************************************************
Jay Flaherty fty@utk.edu
"Once in awhile you get shown the light, in the strangest of places if
you look at it right" - R. Hunter
**********************************************************************
------------------------------
Date: Tue, 28 Apr 1998 12:22:10 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: cgi-lib.pl or CGI.pm?
Message-Id: <3546c8c2.24882727@news.tornado.be>
I R A Aggie wrote:
>And as far as I know, no one is updating/bug-fixing cgi-lib.
This site would seem to contradict that:
http://cgi-lib.stanford.edu/cgi-lib/
HTML page last updated February 20, 1998.
But that still leaves the original question unanswered: what bugs?
Bart.
------------------------------
Date: Tue, 28 Apr 1998 13:31:01 +0100
From: Jerry Pank <jerryp.usenet@connected.demon.co.uk>
Subject: Re: convert an @array into a single $variable?
Message-Id: <3a4miWAFwcR1Ewiz@connected.demon.co.uk>
In <comp.lang.perl.misc>
Jonathan Feinberg <jdf@pobox.com>, writes:
>mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
>
>> Or you could just write
>>
>> $scalar = "@array";
>>
>> if you want the elements separated by spaces.
>
>Or, more precisely, separated by the contents of the $" variable,
>which is ' ' by default.
>
Oh. I like that for browser work. Like that a lot.
local $" = "<BR>\n";
print "@array";
Cool!
--
Jerry Pank... is going back to study the special $ vars yet again!
BTW Great hack. 3D flyaround in Excel97 (Look for the credits)
Excel97 Win95/NT must have active-x installed.
Open Excel, F5, enter X97:L97 return, press tab, ctrl+shift
& click chart wizard icon. Enjoy
------------------------------
Date: Tue, 28 Apr 1998 07:22:21 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Defending Abigail (was: Defending Perl)
Message-Id: <pudge-2804980722400001@ppp-10.ts-1.kin.idt.net>
In article <6i3irk$ltl$1@client3.news.psi.net>, abigail@fnx.com wrote:
# Zenin (zenin@archive.rhps.org) wrote on MDCCI September MCMXCIII in
# <URL: news:893725518.611954@thrush.omix.com>:
# ++ Abigail <abigail@fnx.com> wrote:
# ++ >snip<
# ++ : Uhm, uhm, I find perl one of the hardest things to install.
# ++
# ++ ...Uhm, uhm, what's so hard about:
# ++
# ++ sh Configure
# ++ make
# ++ make install
#
# As I said before. Lots and lots of questions, in an illogical order.
I have spent many an afternoon trying to get perl to compile. In fairness
to perl, though, it is usually when I think I know better than Configure.
:-)
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: Tue, 28 Apr 1998 14:13:31 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: error opening Database file
Message-Id: <Es4nIJ.JyI@world.std.com>
"Adam Klein" <a_klein@ix.netcom.com> writes:
>open(DATABASE, "$database") || die "Content-type: text/html\n\nCannot open
>database! " . $database;
>but I get an error returned in the browser that says that it can't open the
>database file. Why is this happening? Do I need to create the file first?
>How do I fix this problem?
Yes, if you open a file for read access, it must exist. I assume the
reason for this design decision is that if there is no reason to read
no data, and so opening a non-existant file for reading must be an
error.
Since this appears to be a CGI script, there may be other reasons why
you can't open the file as well. The permissions of the user running
the CGI script may be different than you when you are logged in. The
current working directory may not be what you expect it to be.
On most HTTP servers that communicate to programs using the CGI
protocol, when the server returns an error to the client, it also
places more detailed descriptions of the error in a log file. Usually
perl's STDERR is redirected to the log file, and then you can find
what perl (or your program) is saying is wrong.
You might also want to include the value of the "$!" variable in your
error message. when open() fails, it sets this variable to either
error number of your error, or text describing your error. (The
variable returns text when using in a way that a string would be
appropriate. It returns a numeric value when a number would be so.)
You might also be best off by getting a copy of perl to run on your
own machine. That way you can check the functioning of the script
before you have the HTTP server run it on your behalf.
There are a couple of other things that might interest you. You might
want to take a look at the document <URL:http://language.perl.com/
CPAN/doc/FAQs/cgi/idiots-guide.html> It goes through some common
problems when writing scripts that use the CGI protocol.
You might also want to look at the CGI.pm module.
<URL:http://reference.perl.com/module.cgi?CGI> and especially its
"fatalsToBrowser" mode, which will redirect perls error messages to
the web browser that initiated the transaction that caused the HTTP
server to run your script.
--
Andrew Langmead
------------------------------
Date: Tue, 28 Apr 1998 14:26:26 +0200
From: Steve Hardy <steve.hardy@wipo.int>
Subject: help for beginer ..
Message-Id: <3545CAF2.47EFFD0A@wipo.int>
Hello,
I'm a beginer I know how to create html tag but now I want to start
creating forms on my inet page. I've seen a lot of pgm in CGI and Perl
but I dont understand the difference.
Please give me advice on how I should procede to be able to create forms
for my home page. Should I learn SGI or Perl ??? Where I could find the
references...
Thanks for your help
------------------------------
Date: Wed, 22 Apr 1998 12:35:17 +0200
From: Denis DORR <dorr@cetrel.lu>
Subject: Re: Help with regular expression
Message-Id: <353DC7E5.7B50D16B@cetrel.lu>
Quentin Fennessy wrote:
>
[ snip ]
> I could not compress this to one line (the ultimate $NEWDATE assignment).
> How can I say something like $NEWDATE = $DATE =~ s/something/else/?
>
> --
> Quentin Fennessy AMD, Austin Texas
> Secret hacker rule #11 - hackers read manuals
^^^^^^^^^^^^^^^^^^^^
I really like this !
Try perldoc perlop :
...
Assignment Operators
... some lines here ...
Unlike in C, the assignment operator produces a valid lvalue.
Modifying an assignment is equivalent to doing the assignment and
then
modifying the variable that was assigned to. This is useful for
modifying a copy of something, like this:
($tmp = $global) =~ tr [A-Z] [a-z];
Sorry Quentin, I couldn't resist. :-)
--
HTH.
dorr@cetrel.lu
------------------------------
Date: Tue, 28 Apr 1998 11:47:23 +0100
From: Matt Sergeant <msergeant@ndirect.co.uk>
To: Nervick <nervick@bewellnet.com>
Subject: Re: HELP! PerlScript
Message-Id: <3545B3BB.9E6D693A@ndirect.co.uk>
Nervick wrote:
>
> Does anyone know where I can find documentation on PerlScript?
Check my FAQ:
Perl-Win32-ASP FAQ
==================
http://www.geocities.com/SiliconValley/Way/6278/perl.html
------------------------------
Date: Tue, 28 Apr 1998 05:47:22 -0600
From: greene@gucc.org
Subject: Re: How to add \ to an email address
Message-Id: <6i4c3q$jjf$1@nnrp1.dejanews.com>
In article <6i2pgn$ncn$1@nnrp1.dejanews.com>#1/1,
spencer@luckman.com wrote:
>
> How do I add \ to a string that contains @ and . characters in Perl?
To answer your question, and not question your motives, I would suggest
$str = 'some.name@some.domain.com' ;
$str =~ s/([\.\@])/\\$1/g ;
print $str ;
which prints, as expected
some\.name\@some\.domain\.com
HTH,
JAGreene
--
# James Greene - Informatics Consulting - D-79539 Loerrach, Germany
# Internet: www.gucc.org/greene/consult - greene@gucc.org
# PGP Fingerprint: 8930 41E7 351B 56D8 801C D4D9 4C76 AF0F E24E F307
perl -we "$_=join'<',qw{d2by' f5e;f4z($iu w0@86yo=&ae b!097)l(&aa8vme
b$*};$_=unpack'u*',uc;print"
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 28 Apr 1998 15:42:16 +0100
From: "Frank L. Quednau" <quednauf@nortel.co.uk>
To: tito@cemax.com
Subject: Re: JavaScript to Perl var passing
Message-Id: <3545EAC7.48D542B9@nortel.co.uk>
> 1) How can I pass this array to Perl so that I can save the info to a
> file? I thought of using ACTION=open, append and close and pass the info
> to the query string.
This is more of a Jscript question, methinks. However, form elements are
editable objects within a Jscript. So you could possibly use hidden form
elements, passing the values of the Jscript to those elements, and finally
submit that to the perl script.
2) Does anyone know how to call a Perl script from JavaScript without
using the Submit button?
Again, more of a Jscript thingy, but a cool idea nonetheless. It answers
pretty much your first question. Search for a Jscript reference on the web
and look for the command in Jscript to open a URL. There are many ways you
can do that. You can open in the same window, or you can create a new
window object where you can in fact set some properties, eg get rid of the
menubar, scrollbars, etc. Anyway, you can then form the called URL with
your Jscript, and in there you could then include the variables you are
working with and pass them to your perl script as you would do with any
URL. I like the idea and I think I'll do some work on that, however, I
can't tell you anything about the syntax right now, and you should get more
informed on Jscript.
> 3) I have various arrays with info, and I'd like to save them at once.
> Any suggestions?
See top.
--
____________________________________________________________
Frank Quednau
Phone: +44 (0)1279 402447
http://www.surrey.ac.uk/~me51fq MailTo:F.L.Quednau@bnr.co.uk
____________________________________________________________
------------------------------
Date: Tue, 28 Apr 1998 14:28:52 +0200
From: "Guy Einy, EPN" <epnguy@sinfor.it>
Subject: Mutliple emails
Message-Id: <3545CB84.8FEBA302@sinfor.it>
Hi,
I'm trying to write a program that will send email to multiple users.
I've tried using the following (this is just the relevant code):
foreach $recipient(@recipients) {
send_email($recipient);
}
sub send_email {
$recipient = $_[0];
open (MAIL, "|$mailprog $recipient");
print MAIL ("To: $recipient\n");
print MAIL ("From: epnguy\@sinfor.it\n");
print MAIL ("Subject: A special offer!\n\n");
foreach $line(@message) {
print MAIL ("$line");
}
close (MAIL);
print "Successfully sent message to: $recipient<br>\n";
}
It woks fine - it does send the message.
The problem is that the From:... and Subject:... gets printed in the
BODY
of the email rather then in the email headers.
This format of print commands works fine for a single message.
Does anybody have any ideas?
Thanks a lot.
Guy
webmaster@europropertynet.com
------------------------------
Date: Tue, 28 Apr 1998 14:43:32 GMT
From: John Porter <jdporter@min.net>
Subject: Re: New boy on the perl block
Message-Id: <3545EC76.1413@min.net>
Richard Cooper wrote:
>
> I am using a combination of perl, IDC/HTX and Active Server Pages to
> query a database. The database if basically a product catalogue and
> ordering system. I only want at the moment verified past customers to
> place orders, so I need to verify the customers identification at the
> beginning before they are allowed to place an order.
>
> Has anyone got any good suggestions as to what techniques are best to
> use to verify the customer is valid, stop anyone else from ordering,
> keep a record of the customer identification throughout there
> ordering, quering of stock and ordering session.
Um, you're not likely to find a perl one-liner that will do this.
In fact, I hope you're doing some serious up-front design work on
this application, esp. including state transition diagrams.
You're going to need to preserve/pass state info between the
invocations of the scripts that compose the applications.
In particular, you better be using the CGI.pm module the CGI
stuff. You can transmit state from one script to the next
via hidden inputs in the html forms. However, since the
thread of execution in a multi-script CGI application is
open-ended, you can't keep state such as "current user" in
a local state store, because they might not ever complete
the session and "log out".
hth,
John Porter
------------------------------
Date: Tue, 28 Apr 1998 07:12:28 -0500
From: Derek Balling <dballing@speedchoice.com>
Subject: Odd Regexp Question
Message-Id: <82E778210F2134E4.2D55884FF8E43598.17BACF09A2DD9CCD@library-proxy.airnews.net>
OK, I'm parsing a message which will contain two different
strings "123456-12" and "987654" (actual numbers will vary,
of course).
Right now I'm doing:
($number_1) = /(\d{6}\-\d{2})/
($number_2) = /(\d{6})[^\-]/
(I know that they will not appear in the midst of a
seven-digit or anything like that, so I'm not concerned
about what appears on either side, EXCEPT that this won't
detect $number_2 if it appears at the very end of the
string.
You're looking for 123456
There is no non-"-" character afterward, so it fails.
Any thoughts on how to achieve this? Can I do something
like:
($number_2) = /(\d{6})([^\-]|$)/
telling it to match 6 digits next to either a non-"-" or the
end of the string? I didn't think that would work, but I'm
open to suggestions.
Derek
------------------------------
Date: Tue, 28 Apr 1998 08:59:41 -0400
From: "Alan McCoy" <a.r.mccoy@larc.nasa.gov>
Subject: Passing a Javascript cookie to a Perl/CGI script
Message-Id: <6i4k5b$pn4$1@reznor.larc.nasa.gov>
I have a page that uses JavaScript to create a cookie with the user's most
recent query data. How can I retrieve and use that same cookie later in a
Perl or CGI script to run a search with that query?
Alan McCoy
a.r.mccoy@larc.nasa.gov
------------------------------
Date: Tue, 28 Apr 1998 14:23:10 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Perl Scripts Newsgroup
Message-Id: <Es4nyM.4K9@world.std.com>
Mikey Vaughan <mikey@in.net> writes:
>Is there a specific newsgroup that can offer assistance for writing cgi
>scripts??
You might want to check with the people who supply you with Usenet
connectivity, and see how you can access their list of
newsgroups. Once you have that, you can search through the file to
find whatever group you want.
For example, one way in which I can get the list of active newsgroups
carried by the company that I buy Usenet connectivity from is the file
/usr/lib/news/active. If I didn't know which groups dealt with the CGI
protocol, and wanted to find one, I may use the "grep" command to
search the file.
~/tmp>grep cgi /usr/lib/news/active
mcgill.general 0000005562 05455 y
comp.infosystems.www.authoring.cgi 0000068295 67858 m
fido7.ru.cgi.perl 0000000337 00133 m
it.comp.www.cgi 0000000122 00107 y
Since comp. is a major Usenet hierarchy, I'd assume that the bulk of
the discussion happens there.
Of course, I could also use perl, especially if I was writing an
article to Usenet and I wanted to keep it on topic.
~/tmp>perl -ne 'print if /cgi/' /usr/lib/news/active
mcgill.general 0000005562 05455 y
comp.infosystems.www.authoring.cgi 0000068295 67858 m
fido7.ru.cgi.perl 0000000337 00133 m
it.comp.www.cgi 0000000122 00107 y
--
Andrew Langmead
------------------------------
Date: Tue, 28 Apr 1998 10:13:06 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Perl/Wall lingo question
Message-Id: <Pine.A41.3.96.980428101110.66756E-100000@ginger.libs.uga.edu>
Don't know about Larry, but ...
scalar n (1846) 1: a real number rather than a vector 2: a quantity (as
mass or time) that has a magnitude describable by a real number and no
direction
Copyright 1994-1998 Encyclopdia Britannica, Inc. and Copyright 1994
Merriam-Webster, Incorporated
I'm guessing the 'real number rather than a vector' might apply.
On 28 Apr 1998, RHS Linux User wrote:
> Hi.
> What is the source of Larry Wall's terminology, or the
> terminology of whoever wrote man perl... ?
>
> I've been programming for years, and I don't recognize
> a lot of the terms, in the sense they're used there.
> e.g. "scalar". I ask because it seems to have a distinct
> style from something else. I do Forth, C, machine code,
> BASIC, and I don't recognize it. PASCAL? Some
> lexical algebra thing?
>
> If you care to comment, please email me.
> Rick Hohensee
> humbubba@cqi.com
---
Brad Baxter, UGA
------------------------------
Date: 28 Apr 1998 09:24:24 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Permutations in hashes make Perl hurt
Message-Id: <6i4la8$n5p$1@monet.op.net>
Keywords: algae ducat moribund replete
In article <6i3qq2$k58@cello.hpl.hp.com>,
Tom Rokicki <rokicki@cello.hpl.hp.com> wrote:
>If the keys of a hash are permutations of a string then Perl
>essentially uses a single linked list as the attached code shows; run
>it and watch Perl go quadratic!
Yes, the hash values for permutations always differ by a multiple of 32.
Since the hash starts out with 8 buckets, and 8 divides 32, all the
items go into the same bucket.
I have a similar program at
<URL:http://www.plover.com/~mjd/perl/badhash.pl>. It does a time
comparison of installing random strings versus special strings that
were compute to have the same hash value:
plover% ./badhash.pl
Normally, it takes me about 2 second(s) to put 10000 items into a
hash. Now I'm going to construct 10000 special keys and see
how long it takes to put those into a hash instead.
(The following reports come at evenly-spaced intervals; see it slow
down at the end:)
I have put 2885 keys into the hash, using 1 bucket(s)
I have put 4080 keys into the hash, using 1 bucket(s)
I have put 4921 keys into the hash, using 1 bucket(s)
I have put 5638 keys into the hash, using 1 bucket(s)
I have put 6218 keys into the hash, using 1 bucket(s)
I have put 6730 keys into the hash, using 1 bucket(s)
I have put 7214 keys into the hash, using 1 bucket(s)
I have put 7662 keys into the hash, using 1 bucket(s)
I have put 8080 keys into the hash, using 1 bucket(s)
I have put 8484 keys into the hash, using 1 bucket(s)
I have put 8863 keys into the hash, using 1 bucket(s)
I have put 9211 keys into the hash, using 1 bucket(s)
I have put 9539 keys into the hash, using 1 bucket(s)
I have put 9877 keys into the hash, using 1 bucket(s)
The 10000 special keys took 86 seconds to put into the hash,
instead of 2 seconds.
But your program is better because it demonstrates something that
might really happen. Mine goes to a lot of work to compute the
special strings, and they are not very plausible. (Several perople
have pointed out ways to do this more easily.)
>I'm currently looking into a better hash function to solve this problem,
>hopefully without introducing any other problems. Any thoughts or
>suggestions?
1. The hash function was chosen partly for good behavior, and partly
for speed. There is a tradeoff here. Both sides are very
important---but speed in the general case is more important than
good behavior in pathological cases.
If you make hashing slower, even a little bit, that is likely to
have a disproportionate impact on Perl's pverall performance,
because the same hashing is used to look up variable names in the
symbol tables every time a variable as accessed by name.
Run a lot of benchmarks before you decide you've done the right
thing.
2. Gnat and I tried hard a few months ago to speed up the hashing.
We couldn't. Everything we did made it worse.
That makes sense. Hashing is a big target. If there were an easy
way to make it faster, someone would probably have done it already.
3. The hash function is
for ( ; *s; s++) {
hash = hash * 33 + *s;
}
If you change the 33 to 34, it will not have the problem you
observed, and it *might* not be a lot slower. Then permutations
will differ by a multiple of 33 instead of a multiple of 32.
The multiplication will probably take longer, and this is one of
those places where a few microseconds *does* make a difference.
But I suppose it's worth a try.
You can find it in hv.h, #define PERL_HASH.
4. It might be more useful to keep the keys in sorted order in the
buckets. That wouldn't eliminate the bad behavior for your
example, but it would decrease it (and every other hash access) by
about half. You could sort the keys by hash value to avoid slow
comparisons.
5. If Perl had an operator for selecting the number of buckets or the
hash function, you could use it here. Then you could say
number_of_buckets %hash, 33; # Instead of 8
and then your program wouldn't hurt so much.
It probably wouldn't be hard to write a tied hash class in C that
supported this. Then people could load it in for special uses and
it wouldn't affect Perl's overall performance.
------------------------------
Date: Tue, 28 Apr 1998 13:13:45 GMT
From: "Chad Peterson" <chad@NOSPAMumr.edu>
Subject: Re: Please stop and help.
Message-Id: <01bd72a7$773663c0$86a72682@P1207393.MDC.COM>
<SNIP>
> My question: How do I compile a perl script on my win95
> machine in order to ftp it to the unix server so it will work?
Since you normally wouldn't compile perl, you have no problem.
Chad Peterson
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". 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 2439
**************************************