[12890] in Perl-Users-Digest
Perl-Users Digest, Issue: 300 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 29 15:07:17 1999
Date: Thu, 29 Jul 1999 12:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 29 Jul 1999 Volume: 9 Number: 300
Today's topics:
Re: CGI to verify the SSN <ehpoole@ingress.com>
Re: Comparing Scalars <cassell@mail.cor.epa.gov>
Re: Comparing Scalars <emschwar@rmi.net>
Re: Easy way to emulate Unix's "sort" command? <emschwar@rmi.net>
Re: File upload with cgi-bin and port to MSQL Please he <ehpoole@ingress.com>
Re: form, binary attachments <again> (Anno Siegel)
Help install <igor@karpaty.uzhgorod.ua>
Re: How to count clicks to HTML link. (Anno Siegel)
Re: How to count clicks to HTML link. (Greg Bacon)
Re: How to determine a date in the past <emschwar@rmi.net>
Re: How to trim a String (Greg Bacon)
Re: How to trim a String (Greg Bacon)
Re: How to trim a String <sariq@texas.net>
Re: OOP question. (Eugene van der Pijll)
Re: paging text <mattk@cybersurf.net>
Re: paging text (Greg Bacon)
Perl doc'ing (think of Jabberwocky) ebrouwer@ssd.usa.alcatel.com
Possible to Change Password for Services? <sweather@fastenal.com>
Re: programming problem <cassell@mail.cor.epa.gov>
Re: Reading the binary files in Perl (I R A Darth Aggie)
Re: Split is coming Back False?!? (John Klassa)
Re: two forms interact with one script? (Garth Sainio)
Re: two forms interact with one script? <nslatius@dds.nl>
Re: using sendmail in .pl <anfi@bigfoot.com>
Re: variation on /^=/ .. /^=cut/ <Allan@due.net>
What is "variable suicide"? <macintsh@cs.bu.edu>
Re: What is "variable suicide"? (Greg Bacon)
Re: Why this not work HELP! <sariq@texas.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Jul 1999 14:46:53 -0400
From: "Ethan H. Poole" <ehpoole@ingress.com>
Subject: Re: CGI to verify the SSN
Message-Id: <37A0A19D.9BC369C9@ingress.com>
Abigail wrote:
>
> wmichaeln@my-deja.com (wmichaeln@my-deja.com) wrote on MMCLVII September
> MCMXCIII in <URL:news:7nnma1$bq3$1@nnrp1.deja.com>:
> == Hello,
> == I need to write the CGI script to verify
> == the SSN ( Social Security Number ).
> == Does anyone know how to do that ?
>
> I would suggest people send in a copy of their SSN card, that
> makes verifying easier.
It would also be helpful if they could include their driver's license and
credit cards just in case there are any problems verifying the SSN.
There really isn't much to verify about an SSN other than that it is nine
digits long in total (keep in mind that FEIN are also nine digits, the
only difference is where the dash(es) is/are located).
--
Ethan H. Poole **** BUSINESS ****
ehpoole@ingress.com ==Interact2Day, Inc.==
(personal) http://www.interact2day.com/
------------------------------
Date: Thu, 29 Jul 1999 11:12:05 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Comparing Scalars
Message-Id: <37A09975.1166F8EF@mail.cor.epa.gov>
jverk@mediaone.net wrote:
>
> I'm having a problem comparing 3 scalars. In english, here's what I'm
> trying to do:
>
> if $scalar1 and $scalar2 and $scalar3 eq ""
> then do this
> else do this
>
> My problem is I don't know the correct way to write the comparison
> between the variables. If all three variables are null, then do this.
> If at least one of the variables has a value (any value) then do this.
> But how do I write this?
Well, you'll probably want to read through the perlop pages
to learn more about this [that is, type 'perldoc perlop' or
read through the HTML version on your machine]. But the
basic idea is that you want to do three separate comparisons,
and put them all together with the Perl equivalent of 'and'.
Now then. Are your variables numeric or string? Perl
provides comparison operators for both cases, and you'll
want to use the correct one. Assuming you have strings,
you *do* want to say
if ($scalar1 eq "")
rather than
if ($scalar1 == 0)
So combine all the pieces:
if ( ($scalar1 eq "") and ($scalar2 eq "") and ($scalar3 eq "") ) {
Note that 'and' has a lower precedence than 'eq' [or any other
comparison operator] and so the three sets of inner parens are
not needed. Except to prevent brain-pain when you go back two
weeks later to re-write something.
If you're really just beginning with Perl, you might want to
look at some of the tutorials on the web. I recommend
http://www.netcat.co.uk/rob/perl/win32perltut.html
and you may also want to buy a copy of "Learning Perl for
Win32 Systems" by Schwartz, Olson, and, umm, some guy who
hates win32 systems.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 29 Jul 1999 12:24:34 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Comparing Scalars
Message-Id: <xkfu2qniaal.fsf@valdemar.col.hp.com>
jverk@mediaone.net writes:
> I'm having a problem comparing 3 scalars. In english, here's what I'm
> trying to do:
>
> if $scalar1 and $scalar2 and $scalar3 eq ""
> then do this
> else do this
>
> My problem is I don't know the correct way to write the comparison
> between the variables. If all three variables are null, then do this.
> If at least one of the variables has a value (any value) then do this.
> But how do I write this?
One misconception to clear up first off: Perl doesn't have "null". It
has "undef", however. These generally serve similar functions, but to
anybody coming at Perl from a C/C++ or Java background, 'null' has a
specific meaning that 'undef' doesn't.
With that out of the way, the one-off answer is:
if(defined($scalar1) || defined($scalar2) || defined($scalar3)) {
print "one has a value\n";
}
else {
print "none has a value\n";
}
If you have a huge mess of them, you can use grep:
if(grep { defined($_) } ($scalar1,
$scalar2,
$scalar3))
{
print "one is defined\n";
}
else {
print "none is defined\n";
}
That's slightly uglier, but it has the advantage that you can just add
another scalar to the list, and it will automatically be tested like the
rest.
Any candidates for Perl mini-golf (which I define as the opposite of Perl
golf-- you try to get as many characters as possible in it :) ?
-=Eric
------------------------------
Date: 29 Jul 1999 12:10:40 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Easy way to emulate Unix's "sort" command?
Message-Id: <xkfzp0fiaxr.fsf@valdemar.col.hp.com>
jimhutchison@metronet.ca (Jim Hutchison) writes:
> Their example was for "the first word after the first number"...
And you just want "the third column". So "perldoc -f split" to show you
how to get the Nth column (the split will replace the regex in the
example), and then use those results as @idx in the example.
Note: that example uses cmp, because it's comparing words. You wans <=>,
because you're comparing numbers.
> I don't know perl enough yet to be creative, so it's not clear to me
> how to change the script to sort on another column.
The key is to understand what it's doing:
@idx = ();
for (@data) {
($item) = /\d+\s*(\S+)/;
push @idx, uc($item);
}
This builds up an array, @idx, that contains the field you want to sort
on for each element in @data. That is, if @data is
("123 45 63 662", "22 443 abc 12fd", "1fj fjs 834 20f"),
then @idx here is
("45", "443", "fjs").
In your case, you'd replace the regex with a split that separates your
columns into an array, and then pick the element of that array (the
column) you want.
@sorted = @data[ sort { $idx[$a] cmp $idx[$b] } 0 .. $#idx ];
This is sneaky; we'll separate it out into two parts. The first part is
the actual sort:
sort { $idx[$a] cmp $idx[$b] } 0 .. $#idx
This is particularly tricky. What you're actually sorting is a list from
(in this example) 0 to $#idx (which is 2). So you're sorting the list
(0, 1, 2)
But, you're not sorting them directly; that would be silly, as they're
already sorted. You're sorting them according to the value of @idx at
those indices. Since @idx, sorted by word index, is ("443", "45",
"fjs"), the result of the sort is (1, 0, 2). Your application specifies
numeric comparison, so you'll use the <=> operator.
What you're doing, essentially, is creating a list of the indices of
@data, if it were sorted-- you don't actually sort @data, you sort its
indices. Get it?
Then you create the sorted list by using an array slice, and indexing it
with your list of sorted indices:
@sorted = @data[ 1, 0, 2 ]; # same as ($data[1], $data[0], $data[2])
^^^^^
This means it's an array slice. "perldoc perldata"
to learn more about array slices.
> Thanks for your patience.
I hope (but doubt-- I'm a lousy teacher) this helps.
-=Eric
------------------------------
Date: Thu, 29 Jul 1999 14:52:51 -0400
From: "Ethan H. Poole" <ehpoole@ingress.com>
Subject: Re: File upload with cgi-bin and port to MSQL Please help!!
Message-Id: <37A0A303.20692998@ingress.com>
Paul Foran wrote:
>
> I need to be able to upload a delimited data table to me ISP's unix
> box. How can I get user to browse to the file to upload and execute a
> perl sctip to accept this file. How Do I pass it onto MSQL table?
One word: Huh???
"cgi-bin" is just a directory, not an application. CGI is just an
interface specification and, again, not an application.
If what sense I can make of your question is at least in the ballpark, it
seems like you have already answered your own question with respect to
uploading the data. As for placing it in an MSQL database you would do
that the same way you would if it were not a CGI application.
--
Ethan H. Poole **** BUSINESS ****
ehpoole@ingress.com ==Interact2Day, Inc.==
(personal) http://www.interact2day.com/
------------------------------
Date: 29 Jul 1999 18:07:34 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: form, binary attachments <again>
Message-Id: <7nq596$1u5$1@lublin.zrz.tu-berlin.de>
Paolo <prinspaul@NOSPAM!hotmail.com> wrote in comp.lang.perl.misc:
>Hi,
>
>Searching the web for the script I need I ended up here.
>I must admit I don't know a damn thing about Perl.
>I've seen some scripts and decided not to get into this because you just
>can't know it all.
>Here's my problem:
>Like many others I am looking for a script with which I can let my website
>visitors attach a binary file from their PC to the form displayed and mail
>it to me.
>Now, please don't send me replies about MIME::Lite and CPAN because like I
>said I don't know anything about perl.
>Does anybody have a script like this to share ?
>Or maybe an example ?
Translation: Solve my problem but don't bother me with pesky
details.
Go away.
Anno
------------------------------
Date: Thu, 29 Jul 1999 21:41:41 +0300
From: "Igor Lior" <igor@karpaty.uzhgorod.ua>
Subject: Help install
Message-Id: <7nq7o4$2i24$1@karpaty.uzhgorod.ua>
Hello!
Help me to install Perl Win32 on server Apache 1.3.6 (Win32)
Igor Lior
------------------------------
Date: 29 Jul 1999 18:15:54 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to count clicks to HTML link.
Message-Id: <7nq5oq$20k$1@lublin.zrz.tu-berlin.de>
Faisal Nasim <swiftkid@bigfoot.com> wrote in comp.lang.perl.misc:
>: Your design is broken. Counting HTTP accesses is impossible. Give
>: it up.
>
>Your challenging me? The best way however are the logs :)
>
>But I think I can hack Apache to call to a Perl script on each request
>(to log the request). That would eliminate the need of a script
>redirection :)
The original request was to count clicks on certain links, with the
additional proviso that these point out of his site. That would be
handled by the browser, no?
Anno
------------------------------
Date: 29 Jul 1999 18:18:38 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How to count clicks to HTML link.
Message-Id: <7nq5tu$9a7$3@info2.uah.edu>
In article <7nr0mh$oo08@news.cyber.net.pk>,
"Faisal Nasim" <swiftkid@bigfoot.com> writes:
: : Your design is broken. Counting HTTP accesses is impossible. Give
: : it up.
:
: Your challenging me? The best way however are the logs :)
False. You're neglecting proxies.
: But I think I can hack Apache to call to a Perl script on each request
: (to log the request). That would eliminate the need of a script
: redirection :)
You still wouldn't catch every fetch.
Greg
--
Isn't it curious how ``page'' has become a colloquial term for the word
``document'' in hypertext, in a medium that does not have pages anymore?
Do we reuse words as soon as they are freed up by technology? Do we reuse
those of whose destruction we can't bear to be reminded? -- Jutta Degener
------------------------------
Date: 29 Jul 1999 12:12:46 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: How to determine a date in the past
Message-Id: <xkfwvvjiau9.fsf@valdemar.col.hp.com>
Steve Walker <Steve.Walker@ing-barings.com> writes:
> Does anyone know of a way of determining a date in the past, by counting
> back a specified number of days? Ideally the date would be returned as
> an integer, i.e. YYYYMMDD.
>
> Are there any Perl libraries which provide such a function?
You probably want Date::Manip. See CPAN for more info.
-=Eric
------------------------------
Date: 29 Jul 1999 18:15:46 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How to trim a String
Message-Id: <7nq5oi$9a7$1@info2.uah.edu>
In article <MPG.120a166ec1287e2b989d6c@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) writes:
: In article <7npqsn$6vs$1@info2.uah.edu> on 29 Jul 1999 15:10:15 GMT,
: Greg Bacon <gbacon@itsc.uah.edu> says...
: > In article <37a063ba@discussions>,
: > "Amyn " <amynuk@aol.com> writes:
: > : I am a beginner in PERL and I wanted to know how to trim a String
: >
: > That's a FAQ. Visit <URL:http://www.perl.com/perl/faq/> for your answer.
:
: Assuming a 'common-usage' meaning for 'trim' (strip leading and trailing
: spaces) that the next sentence would seem to contradict.
That's why I treated the two separately.
: > : I wanted to get rid of all spaces in a string
: >
: > $str =~ s/\s+//g;
:
: Why do we persist in showing inefficient solutions, when the efficient
: ones are just as easy to learn?
:
: $str =~ tr/ //d;
In a language that proudly proclaims that there's more than one way to
do it, there's no reason these two examples should compile differently
after optimization. Still, if blazing execution speed is at the
forefront of one's needs, there are better choices than Perl.
: Or, as you seem to have interpreted 'all spaces' to mean 'all white-
: space characters',
I didn't have a clear definition. If code does something other than
what Amyn wants, then it would be up to Amyn to fix it.
Greg
--
Anger is a gift.
-- rage against the machine
------------------------------
Date: 29 Jul 1999 18:16:50 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How to trim a String
Message-Id: <7nq5qi$9a7$2@info2.uah.edu>
In article <7nr0j7$ovu1@news.cyber.net.pk>,
"Faisal Nasim" <swiftkid@bigfoot.com> writes:
: That wouldn't remove all the _spaces_, actually it will remove all spaces,
: but some other things (things?) too.... :P
I can't help it if people refuse to clearly specify what they want.
Greg
--
When Galileo turned his telescope toward the heavens, and allowed Kepler to
look as well, they found no enchantment or authorization in the stars, only
geometric patterns and equations. God, it seemed, was less of a moral
philosopher than a master mathematician. -- Neil Postman
------------------------------
Date: Thu, 29 Jul 1999 13:07:25 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How to trim a String
Message-Id: <37A0985D.A8F8F0E4@texas.net>
Amyn wrote:
>
> I am a beginner in PERL and I wanted to know how to trim a String
> I wanted to get rid of all spaces in a string
>
perlfaq4:
How do I strip blank space from the beginning/end of a string?
- Tom
------------------------------
Date: 29 Jul 99 18:25:01 GMT
From: pijll@phys.uu.nl (Eugene van der Pijll)
Subject: Re: OOP question.
Message-Id: <pijll.933272701@ruunat.phys.uu.nl>
In <m1vhb32w7a.fsf@halfdome.holdit.com> merlyn@stonehenge.com (Randal L. Schwartz) writes:
>>>>>> "Eugene" == Eugene van der Pijll <pijll@phys.uu.nl> writes:
>Eugene> local @ISA = ($self->{name} eq 'blah'? @_ISA : reverse @_ISA);
>I believe this will either blow the lookup cache (bad), or use bad
>elements from the lookup cache (bad). In either case, that's bad.
>Don't be messing with @ISA more than you have to.
>Just because you *can* change @ISA at runtime doesn't mean you must. :)
What do you mean by 'this blows up the lookup cache'? Does it corrupt
cache, or only delete it?
According to perlobj,
Changing @ISA or defining new subroutines invalidates the
cache and causes Perl to do the lookup again.
So I assume that the behaviour of my program is well-defined. Or has
this changed in newer versions of perl?
It does have a very large perfomance penalty, and it looks ugly too.
Are these the reasons you dislike my code? In that case I would have
to agree with you, I think. But is the code really worse than the
original exercise?
--
\
Eugene van der Pijll : pijll@phys.uu.nl
--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--
------------------------------
Date: Thu, 29 Jul 1999 12:12:24 -0700
From: Matt <mattk@cybersurf.net>
Subject: Re: paging text
Message-Id: <37A0A798.3C9CE689@cybersurf.net>
you need to read _more_ documentation
Matt
John Pavlakis wrote:
>
> How do I page text read from STDIN or a file so it does not scroll all at
> once? I am using NT and Unix. Thank you.
>
> --
> John Pavlakis
> Systems Administrator
> http://www.virtualcommunitiesinc.com
> Remove the "remove.me" from my email
> johnp@vcimail.com.remove.me
------------------------------
Date: 29 Jul 1999 18:43:08 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: paging text
Message-Id: <7nq7bs$9kk$1@info2.uah.edu>
In article <37A0A798.3C9CE689@cybersurf.net>,
Matt <mattk@cybersurf.net> writes:
: you need to read _more_ documentation
In this case, it could also be better to read less documentation. :-)
Greg
--
The great mass of men lead lives of quiet desperation.
-- Thoreau
------------------------------
Date: Thu, 29 Jul 1999 13:30:58 -0500
From: ebrouwer@ssd.usa.alcatel.com
Subject: Perl doc'ing (think of Jabberwocky)
Message-Id: <Pine.SO4.4.05.9907291131180.987-100000@sun1072.ssd.usa.alcatel.com>
For your amusement (and with apologies to Lewis Carroll) I give you:
Perl doc'ing
Twas normal, whilst upon a quest,
To seek the man-pages with zest.
So, confident of quick success,
He typed 'man perl' and found a mess.
Beware the perl-docs, my son!
There's more to it and that's the catch!
You must wade deep and deeper, then
sometimes on a different branch!
He brought three xterms up in sight:
Long time the depths of perl he'd plumb
Till wrested he from a module free,
a snippet useful as a sum.
And still incredible in size,
The perl docs, with references galore,
stood glowing o'er his cluttered floor.
"It cannot be understood!"
'man this', 'man that' and all in all
The perl docs came to make some sense.
He persevered, and standing tall
held fragments gleaned by his attempts.
And hast thou tamed the perl docs?
You're on your way, intrepid boy!
"I can use this any day!"
He chortled in his joy.
Tis normal, whilst upon a quest,
To seek the man pages, with zest;
And perl docs too, no more to shun --
To learn some perl, is to have won.
Hope you like it.
--Ernie
|Ernest D. Brouwer | Alcatel USA, Inc. |voice: +1.972.519.3088 |
|"Christus vincit; | m/s ain-d | fax: +1.972.519.3700 |
| Christus regnat; | 1000 Coit Rd. |email:Ernie.Brouwer@usa.Alcatel.com|
| Christus imperat"| Plano, TX 75075-5813 | BrouwerE@uSA.net |
------------------------------
Date: Thu, 29 Jul 1999 12:24:32 -0500
From: "Sam Weatherhead" <sweather@fastenal.com>
Subject: Possible to Change Password for Services?
Message-Id: <7nq2og$2p55@enews2.newsguy.com>
Can perl change the underlying password that is being used for
a service to logon with? If so, what module do you use?
Environment:
Build 517
NT 4, SP5
Perl Devlopment Kit 1.14
Any suggestions are appreciated.
Sam Weatherhead
Fastenal
------------------------------
Date: Thu, 29 Jul 1999 11:19:54 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: programming problem
Message-Id: <37A09B4A.DEBDDE6D@mail.cor.epa.gov>
paul_rahe@cissc.canon.com wrote:
>
> You might want to try putting your DOS commands in a BAT file and then
> executing them from within your Perl script with the SYSTEM command.
He shouldn't even need to go that far. He should be able to
execute them directly using the system() command [I know you
meant that rather than SYSTEM but many newbies don't know
Perl is case-sensitive, so I try to be careful about this]
or qx//, or even a pipe open() depending on what he needs
done.
BTW Paul, would you do me a small favor? In this ng we try to
put our responses after the text to which we're responding, in
old-fashioned Usenet style. Could you do that in future? I'd
appreciate it, and then you won't have newsgroup nabobs
nattering on about your style.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 29 Jul 1999 18:47:30 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Reading the binary files in Perl
Message-Id: <slrn7q18i5.47g.fl_aggie@thepentagon.com>
On 29 Jul 1999 17:36:57 GMT, revjack <revjack@radix.net>, in
<7nq3fp$aat$1@news1.Radix.Net> wrote:
+ :Where is this module PSI:ESP and where can I find it?
+
+ Shame on all of you. SHAME.
I knew you would say that.
James - waiting for the Sport::ESPN module...
------------------------------
Date: 29 Jul 1999 18:30:56 GMT
From: klassa@aur.alcatel.com (John Klassa)
Subject: Re: Split is coming Back False?!?
Message-Id: <7nq6l0$en4$1@aurwww.aur.alcatel.com>
On 29 Jul 1999 16:31:22 GMT, Mesarchm <mesarchm@aol.com> wrote:
> open(FILE,"$readdir\\$file") || print ERROR "couldn't open $readdir\\$file $!";
> while ($line=<FILE>)
> {splitit($line) || print ERROR "$!\n";}
> close(FILE) || print ERROR "couldn't close $file $!";
So, um, what does "splitit" do?
--
John Klassa / Alcatel USA / Raleigh, NC, USA
------------------------------
Date: Thu, 29 Jul 1999 14:15:24 -0400
From: modred@shore.net (Garth Sainio)
Subject: Re: two forms interact with one script?
Message-Id: <modred-2907991415240001@gniqncy-s06-44.port.shore.net>
In article <37A09274.34C8A7AE@dds.nl>, Niek Slatius <nslatius@dds.nl> wrote:
!! Hi people,
<snip>
!!
!! I have two forms in one HTML page. Both have their own submit button.
!! The FORM tags both call for the same perlscript in the ACTION variable.
!! Both forms have one hidden field each for recognision purposes. Lets say
!! the NAME values of each is resp. name1 and name2. Thus if one submit
!! button is being clicked it sends the NAME value of the HIDDEN tag from
!! the appropriate form.
you could try naming the submit buttons differently and seeing which one
comes back with a defined value. Are you using CGI.pm to do this? If not,
you probably should be. Without the actual code it is pretty difficult to
give you much more direction on what is going wrong.
Garth
--
Garth Sainio "Finishing second just means you were the
modred@shore.net first to lose" - anonymous
------------------------------
Date: Thu, 29 Jul 1999 20:37:50 +0200
From: Niek Slatius <nslatius@dds.nl>
Subject: Re: two forms interact with one script?
Message-Id: <37A09F7D.3BC6516A@dds.nl>
Garth Sainio wrote:
> you could try naming the submit buttons differently and seeing which one
> comes back with a defined value. Are you using CGI.pm to do this? If not,
> you probably should be. Without the actual code it is pretty difficult to
> give you much more direction on what is going wrong.
Hey Garth,
Thanx for your reply.
The problem is, I don't have submit buttons, but buttons which call for a
javascript function. This javascript function checks whether the data is correct
and if so it submits the appropriate form.
This is the perl code:
----------------------------------------------------------------------
#!/usr/bin/perl
# insert code for parsing incoming formcode to be handled in perl
require "formparse.pl";
$lid="leden.txt";
$bel="belang.txt";
# if the hidden field with NAME="name1" is being send open LID file etc.
if($FORM{'name1'})
{
open(LID,">>$lid") || die "can't open file\n";
print LID $FORM{'lid'}, " ", $FORM{'emailLid'}, "\n";
close LID;
chmod 0777,"$lid";
}
# else if hidden field with NAME="name2" is being send open BEL file etc.
elseif($FORM{'name2'})
{
open(BEL,">>$bel") || die "can't open file\n";
print BEL $FORM{'belang'}, " ", $FORM{'emailBelang'}, "\n";
close BEL;
chmod 0777,"$bel";
}
----------------------------------------------------------------------
Hope this is more vivid for you to analyse. Thanx!!
BTW... what's CGI.pm? Some debugging tool? (I'm a newbie, forgive me)
Niek
------------------------------
Date: Thu, 29 Jul 1999 20:36:23 +0200
From: Andrzej Filip <anfi@bigfoot.com>
Subject: Re: using sendmail in .pl
Message-Id: <37A09F27.87C7C30F@bigfoot.com>
Christian Hans wrote:
> I user a sendmail in a perl script, and it works well, but know I want to
> add a BCC recipient ... what is the syntax ?
>
> print MAIL "BCC: name\@domain.com";
open( MAIL, "| /usr/lib/sendmail -oi -t") or die "Can't open sendmail\n";
# -t - get recipient list from headers
# -oi - single dot is not end of message
my BCC='name@domain.com';
print MAIL << "THE_END" ;
Subject: test
BCC: ${BCC}
Message Body
THE_END
close(MAIL);
defined($?) or die "Total disaster\n";
$? and die "Sendmail exit code $?\n";
--
Andrzej (Andrew) A. Filip | fax: +1(801)327-6278
anfi@bigfoot.com | anfi@polbox.com | http://bigfoot.com/~anfi
Postings: http://deja.com/profile.xp?author=Andrzej%20Filip
Who refuses a better job offer ?
------------------------------
Date: Thu, 29 Jul 1999 14:08:30 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: variation on /^=/ .. /^=cut/
Message-Id: <7nq5ie$2ct$1@nntp5.atl.mindspring.net>
Keith A Arner wrote in message ...
:Say I have the following file (line numbers added for discussion
:purposes):
:
:1: #!/usr/local/bin/perl
:2: =head1 Foo
:3:
:4: Bar
:5:
:6: =cut
:7:
:8: use strict;
:
:If I run it through: while(<>) {print unless /^=/ .. /^=cut/}
:I will get lines 1,7-8. Great.
:
:If I run it through: while(<>) {print if /^=/ .. /^=cut/}
:I will get lines 2-6. Fine.
:
:What if I want to print the lines between (but not including) the
:delimiters? In this example, lines 3-5. That is, I want the
transition
:states of either side of the flip flop to evaluate to false, rather
than
:true.
:
:I know I could do something like:
:
: while(<>) {
: if (/^=/ ) {$flag=1; next}
: if (/^=cut/) {$flag=0; next}
: print if $flag;
: }
:
:...but, ICK! Is there an easier way?
Well, here is one way:
while(<FH>) {print if (/^=/../^=cut/) > 1 and !/^=cut/}
Evalutaions of ICK factor and ease are left to the beholder.
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
Algren's Precepts:
Never eat at a place called Mom's. Never play cards with a man named
Doc. And never lie down with a woman who's got more toubles than you.
------------------------------
Date: 29 Jul 1999 18:22:44 GMT
From: John Siracusa <macintsh@cs.bu.edu>
Subject: What is "variable suicide"?
Message-Id: <7nq65k$2fr$1@news1.bu.edu>
Randal Schwartz writes (from the Mod Perl "mini" guide):
> local() creates a temporal-limited package-based scalar, array,
> hash, or glob -- when the scope of definition is exited at runtime,
> the previous value (if any) is restored. References to such a
> variable are *also* global... only the value changes. (Aside: that
> is what causes variable suicide. :)
What is the "variable suicide" thing that he's describing? My
first crack at writing some code to duplicate his explanation is
included below. But it didn't do anything unexpected, so obviously
I'm missing something. Can someone post a tiny code example of
this "variable suicide" phenomenon? Is it a perl implementation
bug, or is it just a "feature" of the language that can sneak up on
you?
---snip---
$foo = 1;
{
local $foo = 2;
$ref = \$foo;
print "\tfoo = $foo\n",
"\tref = $$ref\n";
}
print "foo = $foo\n",
"ref = $$ref\n";
{
local $foo = 3;
print "\tfoo = $foo\n",
"\tref = $$ref\n";
}
print "foo = $foo\n",
"ref = $$ref\n";
---snip---
-----------------+----------------------------------------
John Siracusa | If you only have a hammer, you tend to
macintsh@bu.edu | see every problem as a nail. -- Maslow
------------------------------
Date: 29 Jul 1999 18:46:45 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: What is "variable suicide"?
Message-Id: <7nq7il$9kk$2@info2.uah.edu>
In article <7nq65k$2fr$1@news1.bu.edu>,
John Siracusa <macintsh@cs.bu.edu> writes:
: What is the "variable suicide" thing that he's describing?
[13:44] ettsn% grep -i 'variable suicide' *.pod
perlfaq.pod:filehandles, added commify to L<perlfaq5>. Restored variable suicide,
perlfaq7.pod:=head2 What is variable suicide and how can I prevent it?
perlfaq7.pod:Variable suicide is when you (temporarily or permanently) lose the
perltoc.pod:=item What is variable suicide and how can I prevent it?
perltoc.pod:(Constants), (Scalars), (Variable Suicide)
perltrap.pod:=item * (Variable Suicide)
perltrap.pod:Variable suicide behavior is more consistent under Perl 5.
Greg
--
Christ died for our sins. Dare we make his martyrdom meaningless by not
committing them?
-- Jules Feiffer
------------------------------
Date: Thu, 29 Jul 1999 13:05:30 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Why this not work HELP!
Message-Id: <37A097EA.1B8A4933@texas.net>
Ryan Ngi wrote:
>
> give:
>
> %HASH = ( "k" => [1,2,3] );
>
> $x = $HASH{ "k" }-> [1]++;
>
> print $x;
>
> ...... the result is "2" but i expect "3";...... why this not work !?
At what point (read:precedence) is the increment operation performed?
- Tom
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". 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 V9 Issue 300
*************************************