[11103] in Perl-Users-Digest
Perl-Users Digest, Issue: 4703 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 20 20:05:51 1999
Date: Wed, 20 Jan 99 17:00:22 -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 Wed, 20 Jan 1999 Volume: 8 Number: 4703
Today's topics:
Re: $0 or @ARGV in a one-liner (??) <uri@ibnets.com>
Re: == and = , again (Tad McClellan)
ancestry of perl features <uri@ibnets.com>
Re: ancestry of perl features (Sean McAfee)
Re: arbitrary precision arithmetic (Larry Rosler)
Re: CC via email (Was Re: "Back button" in CGI script) <spam@dikkelul.com>
Re: Changing elements in a text file <iqbal@orangenet.co.uk>
Re: Changing elements in a text file <iqbal@orangenet.co.uk>
Re: Help - simple matching problem. bjm@a2b01118.paralynx.bconnected.net
Re: Help - simple matching problem. (Larry Rosler)
Re: How to best process a large CGI form? <iqbal@orangenet.co.uk>
Re: How to best process a large CGI form? <uri@ibnets.com>
Re: How to link image in Perl script ? <iqbal@orangenet.co.uk>
Re: How to Timeout a Perl Socket Connect?? ()
LOOP (_/ cim \_)
Re: newbie - endless loop on simple program. (Tad McClellan)
Re: Newbie Perl CGIer needs fast help! Posting to URL ((//trxby))
Re: Newbie string question, please help :) (Larry Rosler)
Re: Newbie string question, please help :) <no_spam@no_spam.com>
Re: Perl from the Market viewpoint <uri@ibnets.com>
Re: Perl problem :(Offline mode... <sternji@mail.northgrum.com>
Re: Perl, MySQL, and Hassan shopping cart. birgitt@my-dejanews.com
Re: Problem with Perl script <iqbal@orangenet.co.uk>
Re: protecting scripts (Tad McClellan)
Re: Q: conditional operator and variable assignment (Andre L.)
Re: Q: conditional operator and variable assignment (Andre L.)
Re: text indexes from lists (Tad McClellan)
Re: Using PERL to access SQL <iqbal@orangenet.co.uk>
Re: variable scoping question (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Jan 1999 18:54:05 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: $0 or @ARGV in a one-liner (??)
Message-Id: <3967a133he.fsf@ibnets.com>
>>>>> "MV" == Martien Verbruggen <mgjv@comdyn.com.au> writes:
MV> Another question:
MV> Why is the -e flag passed on in @ARGV?
actually it is being printed from $0 (not @ARGV) which makes some sense,
as that is the 'file' that is being executed.
perl -we 'print "$0\n";'
-e
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Wed, 20 Jan 1999 16:44:59 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: == and = , again
Message-Id: <b9m587.q3n.ln@magna.metronet.com>
Zenin (zenin@bawdycaste.org) wrote:
: Bart Lateur <bart.lateur@skynet.be> wrote:
: : Jim and Paula wrote:
: : >I know they hate to expand reserved words, but it would be nice to
: : >have "equals" for = , and "becomes" for ==
: :
: : It would be nicer still, if those were reversed.
: IYHO, but not likely many others.
I thought he was saying is should be switched to:
"equals" for == and "becomes" for =
That is, switch the aliases, not switch the semantics of
the symbols.
If so, then put me in his camp ;-)
: This has been hashed out many,
: many times.
I think your "This" is not Bart's "this"...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Jan 1999 19:27:32 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: ancestry of perl features
Message-Id: <393e5531xn.fsf@ibnets.com>
i have been pondering perl's ancestry and for curiosity's sake i have
been thinking about which languages (if any) influenced various perl
feature. some are borrowed from one language which borrowed from an
earlier one. some are pure perl from the head of larry and his cohorts.
some are very obvious (or not). here is a starting list. feel free to
add, comment or flame.
math infix ops (+, *, /, etc) C
exponentiation (**) PL/I (others too)
math comparison ops (==, >, ) C (others used = for ==)
assignment ops (+=) C
short circuit ops (||, &&) C (text versions are perl)
bit ops ( |, &, ^, <<, >> ) C
auto-increment/decrement C (magic ++ is perl)
dereference (->) C (from PL/I)
scalar range (..) awk (list .. is perl)
bind (=~) awk
scalars as string or number sh
arrays of scalars csh? (the $a[0] syntax is similar)
tr/// tr, sed y (does anyone use y?)
s/// sed
m// many unix programs (awk,sed,more,etc.)
-p option sed
-n option awk
varying lenghth strings (no \0 needed) sh, PL/I
substr PL/I
grep unix
map lisp
lists lisp, apl
slices apl
hashes awk
flow control (for, while, etc) C
foreach perl
statement modifiers perl?
eval string sh
eval block perl
file test ops sh (perl added many)
file functions C, unix
system call functions C, unix
networking functions C, unix
get*by* functions (gethostbyname) C, unix
glob (<*>) csh
that's enough for me for now. all i can say is that larry is a high
quality thief! :-)
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Thu, 21 Jan 1999 00:49:01 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: ancestry of perl features
Message-Id: <1Qup2.3157$Ge3.13880928@news.itd.umich.edu>
In article <393e5531xn.fsf@ibnets.com>, Uri Guttman <uri@ibnets.com> wrote:
>i have been pondering perl's ancestry and for curiosity's sake i have
>been thinking about which languages (if any) influenced various perl
>feature. some are borrowed from one language which borrowed from an
>earlier one. some are pure perl from the head of larry and his cohorts.
>some are very obvious (or not). here is a starting list. feel free to
>add, comment or flame.
[snip]
ampersand function call syntax -- BASIC (specific variety unknown to me
personally, although the perl man page refers to a "BASIC-PLUS")
More specifically, in at least one variety of BASIC, you could set up a
hook to an assembly-language routine, and then call the routine from BASIC
using a syntax like &FOO, &BAR, etc. The routine could determine the name
that was used to call it, and process the rest of the tokens accordingly.
Anyone else remember keying in long hexadecimal listings from Nibble
Magazine into your Apple II, and then magically being able to do things
like this in BASIC?
10 PRINT "TESTING"
20 &HGR : REM TURN ON SUPER-HI-RES GRAPHICS MODE
30 &HCOLOR=7
40 &HPLOT 0,0 TO 100,100
50 END
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Wed, 20 Jan 1999 16:41:49 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: arbitrary precision arithmetic
Message-Id: <MPG.111017aadd1e16049899af@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <785j38$bff$1@uranium.btinternet.com> on Wed, 20 Jan 1999
21:53:22 -0000, Denny John <denny.john@btinternet.com> says...
> I was checking out the arbitrary precision boast of perl by doing 100
> factorial and noticed that this calculation goes awry after 22!
> ie this
>
> printf "%f\n" , 1124000727777607680000*23 ;
>
> returns :
>
> 25852016738884978212864.000000
>
> which is sort of fine except its missing four zeroes before the decimal
> point. I was using perl 4 and 5.004.
>
> Any ideas ? Can someone try this with perl 5.005xxx and tell me if it works
> ?
I got this on 5.005_02:
25852016738884978000000.000000
But it's the *same* result! You are past the precision of a double-
precision floating-point number, which is what perl uses by default for
arithmetic on integers that are larger than 2**32 - 1 (on a 32-bit
machine).
There are a few modules in CPAN that do arbitrary-precision arithmetic
on integers. I know of Math:BigInt (sp?), but I believe other modules
may be more current.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 21 Jan 1999 01:42:24 +0100
From: "Willem" <spam@dikkelul.com>
Subject: Re: CC via email (Was Re: "Back button" in CGI script)
Message-Id: <785tc7$l5v$1@dinkel.civ.utwente.nl>
>Of course, if the email address supplied is bogus (as Willem's is !;-)
>and the questioner expects me to de-spam it, then -- as they say in New
>Yawk -- fugghdaboudit!
Mine isn't bogus. Mail to 'spam@dikkelul.com' just comes in on one of my
lower priority mailboxes. I don't want to automatically delete this mail and
besides, when I'm bored I spend my time sending complaints to the uplinks of
the spammers :-)
------------------------------
Date: Thu, 21 Jan 1999 00:09:03 +0000
From: iqbal <iqbal@orangenet.co.uk>
To: Artoo <r2-d2@REMOVEbigfoot.com>
Subject: Re: Changing elements in a text file
Message-Id: <36A6701F.5E00F622@orangenet.co.uk>
Artoo wrote:
>
> Hi All
>
> How can you change specific elements in a text file?
>
> EG: Text file:
> hello|test|1234|
> goodbye|tset|4321|
>
> How can you make perl just edit the file and replace 1234 with 5678. Is it
> possible or do you have to bring in the file as an array and s/// the value
> and then right the info back to the file? I'm dealing with large files that
> will use unnecessary processor power to write the entire file each time it
> is changed.
>
> Thanks for any help
> Artoo
Make a call to sed
Iqbal
------------------------------
Date: Thu, 21 Jan 1999 00:09:15 +0000
From: iqbal <iqbal@orangenet.co.uk>
To: Artoo <r2-d2@bigfoot.com>
Subject: Re: Changing elements in a text file
Message-Id: <36A6702B.3D439465@orangenet.co.uk>
Artoo wrote:
>
> Hi All
>
> How can you change specific elements in a text file?
>
> EG: Text file:
> hello|test|1234|
> goodbye|tset|4321|
>
> How can you make perl just edit the file and replace 1234 with 5678. Is it
> possible or do you have to bring in the file as an array and s/// the value
> and then right the info back to the file? I'm dealing with large files that
> will use unnecessary processor power to write the entire file each time it
> is changed.
>
> Thanks for any help
> Artoo
Make a call to sed
Iqbal
------------------------------
Date: 20 Jan 1999 15:39:11 -0800
From: bjm@a2b01118.paralynx.bconnected.net
Subject: Re: Help - simple matching problem.
Message-Id: <x7emopms4g.fsf@a2b01118.i-did-not-set--mail-host-address--so-shoot-me>
>>>>> "Martien" == Martien Verbruggen <mgjv@comdyn.com.au> writes:
Martien> In article <36A640A4.A78D2191@home.com>, Terry Haroldson
Martien> <tharoldson@home.com> writes:
>> #!usr/bin/perl while (<>) { chomp; m/\ACABLE: /gc; $CABLE =
>> /\G\w+/; print "$CABLE\n"; }
>> When I run it on this string: "CABLE: 8(F1) DAILY FAULT COUNT"
>>
>> I was hoping to get "8(F1)" into $CABLE, but it doesn't. When
>> I single
Martien> So, you either change your second match to a /g modified
Martien> one, which will break the results you will get back from
Martien> it, and introduces unnecessary complexity, or you do it
Martien> in one go.
Or, even more lucidly, use split ' ' because you know what you don't
want---the spaces!
--
Brad J. Murray "Cogito ergo am."
ActiveState Tool Corp.
------------------------------
Date: Wed, 20 Jan 1999 16:20:24 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help - simple matching problem.
Message-Id: <MPG.111012a47f89752f9899ad@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36A640A4.A78D2191@home.com> on Wed, 20 Jan 1999 14:46:28 -
0600, Terry Haroldson <tharoldson@home.com> says...
...
> #!usr/bin/perl
You are missing '-w' on the end of that line, and 'use strict' is a good
habit to get into!
> while (<>) {
> chomp;
> m/\ACABLE: /gc;
> $CABLE = /\G\w+/;
You need to read perlre a few times. Assigning the result of a pattern
match gives a boolean, not a matched string.
> print "$CABLE\n";
> }
>
> When I run it on this string:
> "CABLE: 8(F1) DAILY FAULT COUNT"
>
> I was hoping to get "8(F1)" into $CABLE, but it doesn't.
That's a lot of heavy lifting for a simple job.
while (<>) {
($CABLE) = /^CABLE:\s+(\S+)/;
print "$CABLE\n";
}
With 'use strict;' you have to declare $CABLE, which is a Good Thing.
Naming a variable with all caps is a Bad Thing, because it implies
constancy by convention. You could also skip the assignment and deal
with $1, but that is ephemeral and can't be assigned to.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 20 Jan 1999 23:59:48 +0000
From: iqbal <iqbal@orangenet.co.uk>
To: jlatifi@tsicable.com
Subject: Re: How to best process a large CGI form?
Message-Id: <36A66DF4.B6928B6C@orangenet.co.uk>
jlatifi@tsicable.com wrote:
>
> I guess I was unclear. I have a large number of text boxes in the
> form. They are named something like a1,a2,a3,b1,b2,....
>
> Can the values of these objects be loaded into an array using a loop?
> How? Once I get them in there, I think I'll be ok. Thanks for your
> help.
>
> Eldorado
Arent the values already in an array , if you parse the form variables
using say &ReadParse (I'm old, haven't moved to CGI.pm yet :-))
or you could assign each checkbox a name which increments by one, then
run through a loop, add one each time to the variable name, and just pop
the value in.
Hard to say without seeing a little more
iqbal
------------------------------
Date: 20 Jan 1999 19:30:03 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: How to best process a large CGI form?
Message-Id: <391zkp31tg.fsf@ibnets.com>
>>>>> "i" == iqbal <iqbal@orangenet.co.uk> writes:
i> Arent the values already in an array , if you parse the form variables
i> using say &ReadParse (I'm old, haven't moved to CGI.pm yet :-))
CGI.pm has a cgi-lib compatability mode. use it and the rest of CGI.pm is
free for the ride.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Thu, 21 Jan 1999 00:03:49 +0000
From: iqbal <iqbal@orangenet.co.uk>
Subject: Re: How to link image in Perl script ?
Message-Id: <36A66EE5.16511DAD@orangenet.co.uk>
GSX wrote:
>
> For starters, escape the quotes in the image tag:
>
> > print "<CENTER><IMG SRC=\"mainlogo.gif\" HEIGHT=54 WIDTH=577></CENTER>";
>
> Then consider putting the image in a web directory and calling it with
> its web path:
>
> > print "<CENTER><IMG SRC=\"http://www.wubba-wubba.com/images/mainlogo.gif\" HEIGHT=54 WIDTH=577></CENTER>";
>
> If that doesn't help - call a plumber.
>
> Alex wrote:
> >
> > Hello there,
> > I have a problem.
> > I wish to put a image Logo in my perl script. The script is :
> > ----------------------
> > ----------------------
> > print "Content-type: text/html\n\n";
> > print "<CENTER><IMG SRC="mainlogo.gif" HEIGHT=54 WIDTH=577></CENTER>";
> > --------------
> > --------------
> > The image already saved in my cgi-bin directory.
> > However, I cannot run this script. Error appear.
> > Please tell me how to do this.
> > Thank you
> > Alex
Somebody call a plumber ?
Iqbal
------------------------------
Date: 21 Jan 1999 00:47:10 GMT
From: miwako@storm.ph.utexas.edu ()
Subject: Re: How to Timeout a Perl Socket Connect??
Message-Id: <785tee$1g2$1@geraldo.cc.utexas.edu>
Hi. I have a similar problem.
I would like to add a timeout function such as this
to my subroutine which originally was:
sub my_sub_old {
...
@runarray=`$runscript`;
foreach $runline(@runarray) {
...
}
}
I tried modifying it to:
sub sig_alrm_my_sub { $timeout = 1;}
sub my_sub_3 {
...
$SIG{"ALRM"} = 'sig_alrm_my_sub';
alarm 300;$timeout = 0; # timeout after 5 minutes
$ranok=@runarray=`$runscript`;
$SIG{"ALRM"} = '';alarm 0; # reset ALRM trap
($ranok,$timeout) ;
foreach $runline(@runarray) {
...
}
}
But, this does not time out after 5 minutes.
Would someone please tell me what I am doing wrong?
Thank you very much.
Miwako
------------------------------
Date: Thu, 21 Jan 1999 00:00:45 GMT
From: cim@online.ee (_/ cim \_)
Subject: LOOP
Message-Id: <36a66b85.4280864@news.online.ee>
I use rand to get a random filename from an array @files
Then i open the file.
Now I get strings $a $b and $c from that file.
Now I check if $a <= $aa or $b <= $bb or $c <= $cc
and if any of those is true it should go to the beginning (rand ....)
AND if all the files @files have been checked it should give up and
print "I give up";
How could I do it fast. Tried but it didn't work like I wanted it to
(tried many things, but no luck)
help.
------------------------------
Date: Wed, 20 Jan 1999 16:54:44 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: newbie - endless loop on simple program.
Message-Id: <krm587.q3n.ln@magna.metronet.com>
Robert E. John (rjohn@raptor.com) wrote:
: The following code fragment produces an endless loop?
^
^
Yes it does. Does that answer your question? ;-)
You should only end questions with question marks.
Use periods for statements.
English has syntax too...
: $num=0;
: $increment=0.1;
: until ($num == 1.1) {
: Notice the following curious output when $num gets to 5.9
: 5.7
: 5.8
: 5.9
: 5.99999999999999
Perl FAQ, part 4:
"Why am I getting long decimals (eg, 19.9499999999999)
instead of the numbers I should be getting (eg, 19.95)?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 21 Jan 1999 00:01:59 GMT
From: ttxyxexr@airxmail.net ((//trxby))
Subject: Re: Newbie Perl CGIer needs fast help! Posting to URL
Message-Id: <891F97A55818C163.F15D849653229672.E89C0ABB438C41F2@library-proxy.airnews.net>
Get a grip, James.
I am traditionally a Windows programmer who is helping out a client
keep another difficult client happy.
I do program for money. It's how make my living and I do it well.
>+ Does anyone have any expertise in this area who could help me out?
>
>Now, why should we help you earn money without some recompense? Should
>someone send you a rate card? Further, what's wrong with Abigail's suggestion?
Whether I do this for money or not shouldn't ruffle your feathers.
PERL is new to me. I was asking for help in an area all my books
didn't help me learn. If you and Abigail took that to mean that I
wanted you to program the thing for me, then go ride your own guilt
trip. My request was innocent. If you don't want to help anyone, then
don't post.
I finished this earlier today. I only came back to thank everyone who
helped me, who may have posted while I was gone. To my surprise the
last one was you.
Fortunately there are a lot more people willing to point me in a
useful direction than hold all the PERL knowledge as prized secrets.
Mike
------------------------------
Date: Wed, 20 Jan 1999 16:24:06 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Newbie string question, please help :)
Message-Id: <MPG.1110137ec1f148669899ae@nntp.hpl.hp.com>
In article <zqsp2.3141$Ge3.13792461@news.itd.umich.edu> on Wed, 20 Jan
1999 22:05:19 GMT, Sean McAfee <mcafee@waits.facilities.med.umich.edu>
says...
...
> Perl's
> regular expressions can handle just about any text-processing task you can
> imagine. I always feel slightly dirty when I have to resort to substr() or
> index().
Even though they run faster in time-critical situations? :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 20 Jan 1999 18:39:15 -0600
From: "Ban Spam Now" <no_spam@no_spam.com>
Subject: Re: Newbie string question, please help :)
Message-Id: <785t1r$all@sjx-ixn9.ix.netcom.com>
Thanks for all your replies much appreciated :)
------------------------------
Date: 20 Jan 1999 18:59:16 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Perl from the Market viewpoint
Message-Id: <394spl338r.fsf@ibnets.com>
>>>>> "MV" == Martien Verbruggen <mgjv@comdyn.com.au> writes:
MV> In article <785n7g$c8q@bgtnsc02.worldnet.att.net>,
MV> "sysadmin" <charlesjourdan@worldnet.att.net> writes:
>> If I wanted to focus on programming Perl in a UNIX environment, could I
>> expect to a make a living just doing that?
it depends on the market where you are. i am a contractor in boston and
i refuse to work on redmondware. i have used winblows as an x terminal
(usually exceed), but no further. i am trying to do only perl with mixed
success. my current contract is just right, perl hacking of text files
and stuff on unix (solaris).
i have gotten this kind of work both directly and thru agencies. if i
were to market myself better, i probably could do just perl/unix
forever. also there are teleprojects (seems to be mostly web/cgi) that
are commonly perl/unix but finding them can be tricky if they don't find
you.
i am planning on creating a perl jobs mailing list (soon as i get my new
mailing setup working). that might help.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Thu, 21 Jan 1999 00:11:52 GMT
From: "James M. Stern" <sternji@mail.northgrum.com>
Subject: Re: Perl problem :(Offline mode...
Message-Id: <36A670C8.14E90C9B@mail.northgrum.com>
Andrew Fry wrote:
>
> In article <36A626B6.948C9E72@mail.northgrum.com>, James M. Stern
> <sternji@mail.northgrum.com> writes
> >Herein, a gentle reply to a point of view that usually draws harsh ones.
>
> Gentle ? Perhaps. Patronising ? Certainly!
I intended only the former. The problem is, the posting I replied to
appeared dismissive of manual-reading in general, as if you didn't want
to make the effort to read. You reinforced that impression by asking
something that the debugger or grep could have answered easily. Now
that you've explained otherwise I can answer you better. (Forgetting
those tools was probably just a momentary oversight on your part.)
> [His Perl and CGI reading list]
> Not looking ? Wait a momemt ... I've read:
> * CGI Developers Guide (Sams.Net)
> * Learning Perl (O'Reilly)
> * Programming Perl (O'Reilly)
> * Perl Cookbook (O'Reilly)
> * numerous articles and examples on all the main Perl websites
A good list indeed. (Caveat: I'm not familiar w/ the Sams.Net book.)
>
> I am gradually getting to grips with the Perl documentation, and I
> realize the importance of documentation ... but I dont agree that
> reading documentation always saves time. It depends on how much
> documentation is involved, how well written it is and whether it covers
> the specific areas of interest in the right level of detail. I have read
> countless documents that havent told me what I have wanted to know.
I too have sufferred from incomplete or obscure manuals so you have my
sympathies. But in my experience, the documentation bundled with the
Perl installation is a shining exception, both clear and complete. My
first advice: The online Perl manual is worth reading and will save you
much time.
Second advice: As my prior posting said, don't forget the power of
grep. The source code fills gaps in the documentation. This I find to
be one of the greatest pluses of Open Source.
> [...]
> >I'm saying: Read the manual. You owe it to your customer and yourself.
>
> I guess you could use this response to *every* new query that arises on
> this newsgroup.
Not every or why have a newsgroup? Alas, too many. Yours masqueraded
as one.
> I do read manuals. I'll wager a bet that I've read more ISO, ITU
> documents, RFCs, UNIX man pages, NT SDK documents, etc ... than you
> have.
This could be construed as patronizing. :-) FYI, I too read ISO
documents, RFCs and man pages. But let it ride. I have no quarrel with
anyone who puts forth an effort.
> But please try not to be so bloody patronising.
See above.
--
James M. Stern Northrop Grumman Corp. Hawthorne, CA
Opinions expressed above are not necessarily my employer's.
------------------------------
Date: Thu, 21 Jan 1999 00:33:32 GMT
From: birgitt@my-dejanews.com
Subject: Re: Perl, MySQL, and Hassan shopping cart.
Message-Id: <785sks$9e8$1@nnrp1.dejanews.com>
In article <27551-36A428B8-49@newsd-104.iap.bryant.webtv.net>,
KernelKlink@webtv.net wrote:
> I am on a UNIX machine running Apache. The server supports Perl, MySQL,
> and the Hassan shopping cart script that I want to use.
>
> Can anyone tell me if the following can be done with Perl script(s)
> Interfacing with the shopping cart and the MySQL database?
>
> "When someone goes to a product page on my site I want the current
> number of items in stock to display next to the item. When the person
> orders a product via the shopping cart "add to cart" option, I want the
> MySQL database to be debited that item at checkout time so that the next
> person to visit the product page will see the current number of that
> item in stock."
>
> I'm a do-it-youselfer, so I just need to know if it CAN be done before I
> roll up my sleeves and dig in.
>
>
Ask on the minivend-users@minivend.com mailing list. MiniVend is a shopping
cart package written in Perl, which runs on Unix and uses MySQL among other
databases. You might look at the source code too and possibly save yourself
some time in not reinventing the wheel.
B.Funk
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 21 Jan 1999 00:05:04 +0000
From: iqbal <iqbal@orangenet.co.uk>
To: jamion@geocities.com
Subject: Re: Problem with Perl script
Message-Id: <36A66F30.8C109F34@orangenet.co.uk>
jamion wrote:
>
> where is the code for &readparse?
>
> John wrote:
>
> > I am (a newbie) getting an error message
> > 'premature ending of script' for the
> > following:
> >
> > #!/usr/bin/perl
> > #
> > &readparse;
> > print "Content-type: text/html\n\n";
> > #
> > #*****************BEGIN BODY*************
> > print "<h1>Thank you for filling out the form</h1>";
> > $firstname = $value[0];
> > $lastname = $value[1];
> > $email = $value[2];
> >
> > print "Your first name is $firstname<BR>";
> > print "Your last name is $lastname<BR>";
> > print "Your e-mail is $email<BR>";
> >
> > Can anyone spot the problem?
> >
> > john
You are using ReadParse but dont seem to have it in your script, or you
maybe calling it from another script, in that case you need to 'require'
that script
Iqbal
------------------------------
Date: Wed, 20 Jan 1999 16:46:43 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: protecting scripts
Message-Id: <jcm587.q3n.ln@magna.metronet.com>
Piers Cawley (pdcawley@bofh.org.uk) wrote:
: Hitler.
: Therefore, in the interests of mental bandwidth, can we kill this
: thread now?
It appears you already have ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 20 Jan 1999 19:24:23 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Q: conditional operator and variable assignment
Message-Id: <alecler-2001991924230001@dialup-515.hip.cam.org>
In article <36a654f3.347163633@news.jpusa.net>, epement@jpusa.chi.il.us
(Eric Pement) wrote:
> 5 == 2 + 3 ? $a = "true" : $a = "false";
What you want to do is this:
$a = (5 == 2 + 3) ? 'true' : 'false';
You might want to look at the examples in perlop again.
HTH,
Andre
------------------------------
Date: Wed, 20 Jan 1999 19:39:55 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Q: conditional operator and variable assignment
Message-Id: <alecler-2001991939550001@dialup-515.hip.cam.org>
In article <36a654f3.347163633@news.jpusa.net>, epement@jpusa.chi.il.us
(Eric Pement) wrote:
> I would also like to do a substitution that looks something like this
> -- greatly simplified for readability:
>
> s/^(.)bc/($1 eq "a" ? "A" : "z")ef/ge;
> #
> # if given "abc", print "Aef"
> # if given "bbc", print "zef", and so on for any regex "[^a]bc"
You were close. You just needed to concatenate "ef" with the result of the
preceding operation (you're in /e mode, remember). Using -w would have
told you what was wrong.
s/^(.)bc/($1 eq 'a' ? 'A' : 'z').'ef'/ge;
^
HTH,
Andre
------------------------------
Date: Wed, 20 Jan 1999 18:12:07 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: text indexes from lists
Message-Id: <ncr587.q3n.ln@magna.metronet.com>
sno@ais.org wrote:
: My desire is to have values in a regular array become a text key to
: positions in another array.
You can do this by arranging "another array" as a hash.
(If I am understanding you correctly...)
: For example:
: @list_of_keys ('id', 'name', 'address', 'home phone', 'work phone');
: @list_of_arrays = (
: ['1', 'George', '333 Way Way', 'none', '555-5555'],
: ['2', 'Pattie', '123 Orchard', '555-5555', '555-5555'],
: ['3', 'Gary', '4444 Forest', '555-5555', '555-5555']
: );
: I would like to be able to acquire a column of data from all lists using
^^^^^^^^^
: the key name by position value.
: So that conceptually:
: $list_of_arrays[$num]['id'] would always reference the zero'th list position
: of all records. 'name' would reference list position '1', etc.
^^^^^^^^^^^
You lost me.
(ignoring for now not being able to put a string in [])
$list_of_arrays[0]['address'] should access '333 Way Way'?
If so, that can be done with a list_of_hashes (which you can
construct from the @list_of_arrays and @list_of_keys):
--------------
# use a hash slice
foreach my $raNum ( 0 .. $#list_of_arrays ) {
@{$list_of_hashes[$raNum]}{@list_of_keys} = @{$list_of_arrays[$raNum]};
}
print "$list_of_hashes[0]{'address'}\n";
# ^ ^ curly braces for hash
--------------
Or did you mean for $list_of_arrays[0]['address'] to
access ('333 Way Way', '123 Orchard', '4444 Forest')
If so, then I don't follow the need to have [0] in there.
Seems that $list_of_arrays['address'] could correspond to
that list.
I thought that might be it, since you say "all records" instead
of "each record".
But $list_of_arrays[0]['address'] starts with a $ indicating
scalar, so it cannot be a list.
Or did you want it to be a reference to a list?
: The caveat to this is that depending on the table, the list of keys might
: be different. Thus, for $list_of_another_array[] the table might be
: altogether different, while still using the same code to process the
: list.
: Essentially, the desire is to reference a position with something like this:
: $list_of_arrays[$num]->[*keyname from alternate source*] without having to
: force a look-up compare loop for each call.
The (first part) above does force a lookup compare. Looking up in
a hash is bound to be gobs faster that looking up in an array
though.
: I hope this is clear.
I'm afraid not...
If the code above doesn't do it, try explaining again.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 20 Jan 1999 23:56:08 +0000
From: iqbal <iqbal@orangenet.co.uk>
To: Stewart Eastham <sme@planetpod.com>
Subject: Re: Using PERL to access SQL
Message-Id: <36A66D18.1FD6AE15@orangenet.co.uk>
Stewart Eastham wrote:
>
> We are using PERL to import data from a large amount of text files
> (30,000 files) to a mySQL database. Here is the method I used, but the
> system bogged down (i.e. used up too much processing power, so the ISP
> killed it). Now, I need to come up with another method:
>
> 1. The script loops through all of text the files in a particular
> directory
> 2. It reads in the "key" field from the record contained in the text
> file
> 3. It uses a SQL select command to make sure the "key" is not already in
> the database
> "select firstName from DB where key='$key'"
> 4. If the record is not in there, the PERL script creates a "userName"
> for the record to be entered.
> 5. The script then uses a SQL select command to make sure that userName
> is not already in use in the DB.
> "select firstName from DB where userName='$userName'
> 6. If a record in the DB already has that userName, the script will
> loop, and create a new userName until a unique userName is created for
> that record.
> 7. The record from the text file (along with its newly created
> userName) is entered into the DB.
> "insert into DB values ('$userName', '$key', '$firstName', '$lastName',
> '$address')"
> 8. The text file is deleted.
>
> This process continues through all of the files in the specified
> directory.
>
> The only other method I can think of is to, at the very start of the
> PERL script, import all of the "key" and "userName" fields from the
> mySQL database. Then, instead of querying the SQL DB at least twice for
> each text file, it would just search through a large array maintained in
> the PERL script.
>
> I'm sure this method would take up more RAM (since two arrays with 30,
> 000 entries each would be built), but I'm wondering if it would use less
> processing power, since there would be less queries to the SQL DB. Any
> ideas would be appreciated. Thank you.
>
> stewart eastham
well I'm not sure how often you will have to do this but if its once (or
even if its more than once) set it up locally run it, then simply dump
the db contents and pipe then across remotely to your ISP, or take the
db file, and ftp to them and then thye can just replace it.
The pipe method is probably not that secure (in fact I know it not)
Iqbal
"If you dont take a chance ...you dont stand a chance"
------------------------------
Date: Wed, 20 Jan 1999 17:28:12 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: variable scoping question
Message-Id: <cqo587.q3n.ln@magna.metronet.com>
Brian Lavender (blavender@spk.usace.army.mil) wrote:
: I am having some difficulty with "my".
[snip]
: The "First Instance" output from the write is
: blank. Why is this?
Because the scope of your my()ed variables extends only to
the end of the block.
Your format is beyond the end of the block.
So those variables are not visible there.
You can use local() instead of my() there.
: First Instance
: ---------------
: while (my @row_ary = $sth->fetchrow_array) {
: my ($coemis, $wi_code,$sum_atp_amt,$sum_paid_amt) = @row_ary;
: # notice the my above
: $woruntotob += $sum_atp_amt; $woruntotpd += $sum_paid_amt;
: $~ = ACCOUNTS;
: write;
: }
: format ACCOUNTS = @<<<<<<<<<<<<<<<<< @<<<<<<< @>>>>>>>>>> @>>>>>>>>>>
: @>>>>>>>>>> ___________ __________ __________ _____________ __________
: $coemis, $wi_code,$sum_atp_amt,$sum_paid_amt, $sum_atp_amt-$sum_paid_amt .
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 4703
**************************************