[6560] in Perl-Users-Digest
Perl-Users Digest, Issue: 185 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 26 18:07:17 1997
Date: Wed, 26 Mar 97 15:00:23 -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, 26 Mar 1997 Volume: 8 Number: 185
Today's topics:
------------------- INTERNET PROGRAMMERS' PARADISE --- (Thomas Porter, Ph.D.)
Calling an exported func from DLL using Perl on Win NT/ <ting@platinum.com>
Re: diff. between 0 and "" <rgagnon@ordinox.com>
Re: does open(FH, "pgm arg1 arg2") take only 1 arg? (Joe McCaughan)
Re: getting year from localtime (Abigail)
Re: global my() variable used in foreach() loop loses i <dbenhur@egames.com>
Re: global my() variable used in foreach() loop loses i (Brian L. Matthews)
Re: global my() variable used in foreach() loop loses i <rra@stanford.edu>
Re: Has anyone heard the rumour that Microsoft have bou <zot@ampersand.com>
Help regarding Microsoft's Personal Web Server CGI conf <Gunraj.Singh@atsys.com>
Re: How do I ? .. rand/srand champs read this <rra@stanford.edu>
Re: How do I ? .. rand/srand champs read this <tchrist@mox.perl.com>
How do you verify URL form and location? bartels@a1.western.tec.wi.us
Re: How do you verify URL form and location? (Brian L. Matthews)
Re: interesting text formatting problem <tchrist@mox.perl.com>
Re: limit execution time? <lewisrh@akcity.govt.nz>
Re: Little beginers question <tchrist@mox.perl.com>
Mode field from stat() - How to interpret? (Ed Bachmann)
Re: Mode field from stat() - How to interpret? (Joel Coltoff)
Operating System Variable? <deb@marinbridge.com>
Re: PSCOPE - fast searching techniques <tibbs@hpc.uh.edu>
Re: PSCOPE - fast searching techniques <tibbs@hpc.uh.edu>
q (Anthony Mulligan)
Re: Regular Expresion question. <abennett@stonehill.edu>
Re: regular expression for check lower case (Brian L. Matthews)
sendmail is killing program (Bio4com)
Re: sendmail is killing program <eryq@enteract.com>
trivial perl question from an ignoramus (Robert R. Tucci)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Mar 1997 17:57:39 GMT
From: tporter@dtool.com (Thomas Porter, Ph.D.)
Subject: ------------------- INTERNET PROGRAMMERS' PARADISE ---------------------
Message-Id: <333d637c.32225020@news.one.net>
For 100's of links to The CGI, Perl, HTML, UNIX, Java, JavaScript
& even Dilbert...Please check out the updated Digital Tool Group
Site...
http://www.dtool.com
Best, TP
------------------------------
Date: 26 Mar 1997 20:37:53 GMT
From: "Wen Ting" <ting@platinum.com>
Subject: Calling an exported func from DLL using Perl on Win NT/95
Message-Id: <01bc3a25$c95d30e0$1e2611ac@tingw>
Can someone point me a direction or a book that explains how to write a
Perl script to invoke an exported function from a dynamic link library
(DLL) on Window NT/95 platforms?
Thank you for your help.
wt
------------------------------
Date: Wed, 26 Mar 1997 15:43:41 -0500
From: Robert Gagnon <rgagnon@ordinox.com>
Subject: Re: diff. between 0 and ""
Message-Id: <33398A7D.62D4@ordinox.com>
Susan Starr wrote:
>
> I'm running perl 5.003 and I'm having some trouble telling if a value is
> 0 or blank. The program I'm writing has the user enter some data and
> then tests the data to make sure it is valid.
>
> Here is some code:
>
> if (&isbetween(0,13)) { print "true\n"; }
> if (&isbetween(0,13,"")) { print "true\n"; }
>
> sub isbetween {
> my ($low,$high,$val) = @_;
> return ($val >= $low && $val <= $high);
> }
>
> I would like both of the above cases to be false but they aren't.
> If I add the line:
> if ($val == "") { return 0; }
> to the function isbetween, then, when $val is equal to 0, the function
> returns 0; How can I fix this?
>
> Thanks,
>
> Sue
Hello.
You are using numeric comparison operators on empty strings, which will
be treated
as zero.
If you want to compare the value as strings, use the eq, lt, etc...
operators.\
Bye.
--
Robert Gagnon | "Marketing: The Art of Using the Truth to Fool
Sys Admin | the Consumers" | Opinions expressed are my own.
rgagnon@ordinox.com | Tel:(514) 686-2455 Fax:(514) 686-0239
Ordinox Network Inc., 720 Montgolfier #201, Laval (Qc) CANADA H7W 4Z2
------------------------------
Date: 26 Mar 1997 21:19:28 GMT
From: shiloh@best.com (Joe McCaughan)
Subject: Re: does open(FH, "pgm arg1 arg2") take only 1 arg?
Message-Id: <5hc3t0$bps$1@nntp2.ba.best.com>
Simon Hyde (aka Jeckyll) (shyde@poboxes.com) wrote:
: On 25 Mar 1997 22:42:03 GMT, shiloh@best.com (Joe McCaughan) wrote:
: >Hi,
: >
: >I cannot get the following construction to see more than 1 arg.
: >I'm using perl4.
: >
: >open(JUNK, "start.pl $arg1 $arg2 |);
: >
: You need to close those quotes, and you might also want to get rid of
: any newlines off $arg1 and $arg2 by doing chomp($arg1) and
: chomp($arg2) first.
Thanks for the help folks. The quotes were there, sorry about the
typo. The args after arg1 were not defined, my fault.
It's working now... :)
thanks again,
--Joe
: ---
: Yours Sincerely,
: ,
: () o /| | |
: /\ _ _ _ __ _ _ |___| __| _
: / \| / |/ |/ | / \_/ |/ | | |\| | / | |/
: /(__/|_/ | | |_/\__/ | |_/ | |/ \_/|/\_/|_/|__/
: /|
: \|
: (Simon Hyde)
------------------------------
Date: Wed, 26 Mar 1997 18:03:37 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: getting year from localtime
Message-Id: <E7nwu1.BwI@nonexistent.com>
On Wed, 26 Mar 1997 10:30:12 -0600, Alex Mak wrote in comp.lang.perl.misc:
++ Hi folks,
++
++ I am interested in getting the year in localtime.
++
++ I know I can get the weekday.
++
++ $thisday =(Sun,Mon,Tue, Wed, Thu, fri, Sat)[(localtime)[6]];
++ print $thisday;
++
++ from the camel book, p.185
++
++ I want to be get the year number from the current datetime.
++ Any ideas?
$year = (localtime) [5] + 1900;
Camel, p. 185 + trivial calculus.
Abigail -- Does everything need to be spelled out?
------------------------------
Date: Wed, 26 Mar 1997 11:17:04 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Ron Newman <rnewman@shell1.cybercom.net>
Subject: Re: global my() variable used in foreach() loop loses its value
Message-Id: <33397630.2B25@egames.com>
[mail&post]
Ron Newman wrote:
> In article <5h9tst$crr$1@halcyon.com>,
> Brian L. Matthews <blm@halcyon.com> wrote:
> >In article <5h9idg$9o0@shell1.cybercom.net>,
> >Ron Newman <rnewman@shell1.cybercom.net> wrote:
> >|I am using a global variable, declared my() at the top level, as
> >|the loop control variable in a "foreach" loop.
> >|Instead of getting the expected value of the variable, it instead
> >|finds the variable to be empty. Can anyone explain this?
> >
> >Heavy sigh.
> >
> >Yes, I can explain it, as can the perl manual pages, as can any perl
> >book worth reading, as can the FAQ, as can DejaNews (this has only
> >been discussed what, 7 or 8 times in the past month?).
>
> I don't see this discussed in any of these places. Can you
> provide a more specific reference?
$Heavy_Sigh x 2.
1) Open Camel.
2) Flip to index, look up "foreach"
p631: foreach loops, 24, 100, 536-537
3) p.24... basic stuff nothing interesting
4) p.100... 2nd paragraph:
The variable is implicitly local to the loop and regains
its former value upon exiting the loop. If the variable
was previously declared with <B>my</B>, that variable
instead of the global one is used, but it's still
localized to the loop.
Specific enough?
You do keep the Camel handy don't you? If so,
why not? I could probably give you a 4 step process
that would find the relevant info in the man pages too,
but I think I'll leave that one as an exercise.
Do we really need to give instructions on *basic* searching
and reading skills in this group?
HTH
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
"It's better to be lucky than good." -- Elizabeth Bourne
------------------------------
Date: 26 Mar 1997 11:13:18 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: global my() variable used in foreach() loop loses its value
Message-Id: <5hbsge$bm8$1@halcyon.com>
In article <5habs8$fl1@shell1.cybercom.net>,
Ron Newman <rnewman@shell1.cybercom.net> wrote:
|In article <5h9tst$crr$1@halcyon.com>,
|Brian L. Matthews <blm@halcyon.com> wrote:
|>In article <5h9idg$9o0@shell1.cybercom.net>,
|>Ron Newman <rnewman@shell1.cybercom.net> wrote:
|>|I am using a global variable, declared my() at the top level, as
|>|the loop control variable in a "foreach" loop.
|>|Instead of getting the expected value of the variable, it instead
|>|finds the variable to be empty. Can anyone explain this?
|>Yes, I can explain it, as can the perl manual pages, as can any perl
|>book worth reading, as can the FAQ, as can DejaNews (this has only
|>been discussed what, 7 or 8 times in the past month?).
|I don't see this discussed in any of these places. Can you
|provide a more specific reference?
>From perlsyn:
The foreach loop iterates over a normal list value and sets the
variable VAR to be each element of the list in turn. *The variable
is implicitly local to the loop* and regains its former value upon
exiting the loop.
(Highlighting mine.)
Brian
--
Brian L. Matthews Illustration Works, Inc.
For top quality, stock commercial illustration, visit:
http://www.halcyon.com/artstock
------------------------------
Date: 26 Mar 1997 12:51:26 -0800
From: Russ Allbery <rra@stanford.edu>
To: rnewman@shell1.cybercom.net (Ron Newman)
Subject: Re: global my() variable used in foreach() loop loses its value
Message-Id: <qum3eti9y29.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
Ron Newman <rnewman@shell1.cybercom.net> writes:
> Here's a Perl script whose behavior I don't understand at all. I am
> using a global variable, declared my() at the top level, as the loop
> control variable in a "foreach" loop. Inside the loop, I call a
> subroutine which access the global variable. Instead of getting the
> expected value of the variable, it instead finds the variable to be
> empty. Why?
[snip]
> my $topic;
[snip]
> foreach $topic (@topics) {
> print "In loop: topic is $topic\n";
> subroutine();
> }
Because foreach localizes the value of its loop variable to the loop. The
$topic seen inside the foreach loop won't have the same value as a $topic
outside the foreach loop. Your subroutine is using the global $topic
variable rather than the one localized to the loop.
(I'm not very clear on why someone would consider this a FAQ -- it's
actually a fairly subtle point.)
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 26 Mar 1997 13:46:03 -0500
From: Mark Atwood <zot@ampersand.com>
Subject: Re: Has anyone heard the rumour that Microsoft have bought Perl?
Message-Id: <v64tdymqz8.fsf@colon.dev.ampersand.com>
Douglas Seay <seay@absyss.fr> writes:
>
> Jonathan Tracey wrote:
> >
> > I have it on good authority that Microsoft have aquired the rights to
> > future versions of Perl. If so how long before we get Visual Perl?
> > Any thoughts.
> >
> > Jon..................
>
>
> Troll.
>
> And not even a good one.
No kidding. Just who could the Borg have bought it *from*? Each of the
hundreds of individual contributors retain copyright on their
contribution. Each one of them would have to be "bought off".
Maybe they are thinking of the fact that MS paid Hip to do a NT port?
--
Mark Atwood | Cuius testiculos habes,
zot@ampersand.com | habeas cardia et cerebellum.
------------------------------
Date: Wed, 26 Mar 1997 01:25:12 -0800
From: Gunraj Singh <Gunraj.Singh@atsys.com>
Subject: Help regarding Microsoft's Personal Web Server CGI configuration
Message-Id: <3338EB78.2D9C@atsys.com>
Hi
I am facing a problem regarding MicroSoft's Personal Web Server. I am
using this server on Win 95 system and I'am trying to run some cgi
scripts written in Perl in the cgi-bin directory, which also contains
the Perl for Win32 executable file. What happens is that
1) If I am using MS Internet Explorer then it gives error:
500 Server Error for files with .cgi extension
but opens files with .pl extension.
2) If I am using Netscape 3.0 then it gives the same error for file
with .cgi extension i.e. 500 Server Error but opens .pl file
as Save as to disk. I changed the Option for x-perl application to
run the perl.exe file on win95 but it stills open as save as.
Both Netscape and IE opens cgi scripts if they are running on some other
servers. Certainly it has something to do with Microsoft's PWS.
Is there any way to configure PWS so that cgi scripts run successfully
on both IE and NEtscape and I don't get the above errors. If so, can
anybody help me in that ?
I would greatly appreciate any help.
Gunraj Singh
------------------------------
Date: 26 Mar 1997 12:35:38 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: How do I ? .. rand/srand champs read this
Message-Id: <qum67ye9ysl.fsf@cyclone.stanford.edu>
Tom Phoenix <rootbeer@teleport.com> writes:
> @list = 0..99; # Or whatever list of reasonable size
> {
> my @temp;
> push @temp, splice @list, rand @list, 1 while @list;
> @list = @temp;
> }
Ugh. Lines of code like that make me start to agree with Tom about the
inherent evil of array to scalar automagic conversion. It took a while
peering at that to follow what it does, and first glance was baffling.
I find:
push (@temp, splice (@list, rand ($#list + 1), 1)) while @list;
*much* easier to read.
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 26 Mar 1997 21:07:55 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How do I ? .. rand/srand champs read this
Message-Id: <5hc37b$8mt$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Tom Phoenix <rootbeer@teleport.com> writes:
: push @temp, splice @list, rand @list, 1 while @list;
I'm afraid that I'm starting to not like this no-paren thing.
it's very confusing. How is anyone supposed to know
that it's
push(@temp, splice(@list, rand(@list), 1)) while @list;
push(@temp, splice(@list, rand(@list, 1))) while @list;
See? You can't hope for people to understand that rand() is
a unary function, and the others are list functions. When I
do training, folks are always confused by the parens, so I've decided to
put them in wherever it's a customary function, like open or read.
And certainly you put them in for the unary functions, like abs()
or rand(), since these are strange.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
If I don't document something, it's usually either for a good reason,
or a bad reason. In this case it's a good reason. :-)
--Larry Wall in <1992Jan17.005405.16806@netlabs.com>
------------------------------
Date: Wed, 26 Mar 97 12:49:06 +600
From: bartels@a1.western.tec.wi.us
Subject: How do you verify URL form and location?
Message-Id: <5hbr36$2an@defcon.western.tec.wi.us>
Keywords: URL
Hello,
I want to do some URL validation.
First, I want to validate that the URL text is in the proper format;
ie: http://www.something.com/somedir/subdir/file.html"
Second, once the file form is valid, I want to test the URL to see if
the file actually exists.
Can these things be done? If so, how?
Thanks in advance,
Lyndon F. Bartels
bartels@a1.western.tec.wi.us
------------------------------
Date: 26 Mar 1997 11:19:40 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: How do you verify URL form and location?
Message-Id: <5hbssc$bs9$1@halcyon.com>
In article <5hbr36$2an@defcon.western.tec.wi.us>,
<bartels@a1.western.tec.wi.us> wrote:
| First, I want to validate that the URL text is in the proper format;
|ie: http://www.something.com/somedir/subdir/file.html"
| Second, once the file form is valid, I want to test the URL to see if
|the file actually exists.
Look at the LWP and CGI modules on CPAN.
Brian
--
Brian L. Matthews Illustration Works, Inc.
For top quality, stock commercial illustration, visit:
http://www.halcyon.com/artstock
------------------------------
Date: 26 Mar 1997 14:06:17 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: interesting text formatting problem
Message-Id: <5hbagp$h47$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
elitman@viaduct.com (Eric Litman) writes:
:I have a rather interesting text formatting problem to solve. I have an
:application in which I need to strip HTML from a document to deliver
:it via email as plain text. When simply removing (<.+?>),
That's not good enough. See the FAQ under "How do I strip HTML?"
:I'm left with
:large, blank areas in the paragraphs where the HTML tags once were.
See the FAQ under "How do I reformat a paragraph?"
http://www.perl.com/perl/faq/
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
OOPS! You naughty creature! You didn't run Configure with sh!
I will attempt to remedy the situation by running sh for you...
--Larry Wall in Configure from the perl distribution
------------------------------
Date: Wed, 26 Mar 1997 22:20:52 GMT
From: Rhys Lewis <lewisrh@akcity.govt.nz>
Subject: Re: limit execution time?
Message-Id: <3339A144.93A@akcity.govt.nz>
Anyone got any ideas for how to do this with the NT port of PERL
which has no fork or alarm functions.
Rhys Lewis
Kerry Schwab wrote:
>
> In article <330ca553.12756335@nntp.southeast.net>,
> Murray Stokely <murray@southeast.net> wrote:
> > Is there any way to limit the execution time of a Perl script somehow, in
> >case it gets caught in an infinite loop or something. In csh this would be
> >accomplished with "limit cputime 60".
> > Obviously the goal is just to not make that happen, but I modify this script
> >constantly and its called in a crontab so I don't always test it after each
> >modification and recently a simple typo crippled the machine when about 10
> >processes of the script were stuck in the loop simultaneously.
> > Thanks for any help.
> >
> >
> >Murray Stokely ( murray@southeast.net )
> >http://www.cdrom.com/pub/artpacks
>
> Kindof a large hammer, but....
>
> $TIMEOUT=60;
> use POSIX qw(waitpid);
> if ($pid = fork) {
> $start=time;
> while (! $donewaiting) {
> $donewaiting=waitpid($pid,WNOHANG);
> sleep(1);
> if (time > $start + $TIMEOUT) {
> kill(15,$pid);
> last;
> }
> }
> exit;
> } else {
> #
> # your perl code here
> #
> }
------------------------------
Date: 26 Mar 1997 22:09:58 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Little beginers question
Message-Id: <5hc6rm$bsu$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Eric Poindexter <eric@nettown.com> writes:
:$cwd = system ('pwd')
Why do you want the exit status of the pwd command? Most
people are interested in its output.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"Fanaticism consists of redoubling your efforts when you have forgotten
your aim." --Santayana
------------------------------
Date: 26 Mar 1997 19:59:55 GMT
From: ireb@gibbs.oit.unc.edu (Ed Bachmann)
Subject: Mode field from stat() - How to interpret?
Message-Id: <5hbv7r$r8n$1@newz.oit.unc.edu>
Can anyone tell me how to interpret the 5-digit
mode field delivered by the stat function?
Thanks,
Ed Bachmann
------------------------------
Date: Wed, 26 Mar 1997 20:31:02 GMT
From: joel@wmi0.wmi.com (Joel Coltoff)
Subject: Re: Mode field from stat() - How to interpret?
Message-Id: <5hc11n$l1v@netaxs.com>
In article <5hbv7r$r8n$1@newz.oit.unc.edu>,
Ed Bachmann <ireb@gibbs.oit.unc.edu> wrote:
>Can anyone tell me how to interpret the 5-digit
>mode field delivered by the stat function?
>
>Thanks,
>Ed Bachmann
Your system manuals would be a good place to look. If that doesn't
help try telling the appropriate newsgroup (not this one, it isn't
a perl question) what type of system you have. That will go a long
way to helping them help you. Help me help you.
--
Joel Coltoff
I'd explain it, but there's a lot of math. -- Calvin
------------------------------
Date: Wed, 26 Mar 1997 11:07:09 -0500
From: Debbie Whitten <deb@marinbridge.com>
Subject: Operating System Variable?
Message-Id: <333949AD.3E23@marinbridge.com>
Hello,
is there a built-in variable or way of getting the operating system
in Perl 5? I have written a script that could be run on Unix or
VMS. Right now I'm checking that /etc/passwd exists - if so, it's
Unix, if not, it's VMS. I don't like that solution.
I've looked through the Camel book but couldn't find it. A co-worker
told me to use $^O or $OSNAME but that didn't work.
Thanks!
Deb
------------------------------
Date: 26 Mar 1997 14:03:50 -0600
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
To: mlehmann@prismnet.com (Mark A. Lehmann)
Subject: Re: PSCOPE - fast searching techniques
Message-Id: <ufa913apgih.fsf@sina.hpc.uh.edu>
>>>>> "MAL" == Mark A Lehmann <mlehmann@prismnet.com> writes:
MAL> What I would like to do is search Perl code determining what
MAL> subroutines call other subroutines, where variables and object are
MAL> declared, where variables are assigned, and what files require or use
MAL> other files.
Well, the compiler has to do this for itself; it has the B::Xref tool which
generates a really big report about these things.
MAL> The other part is storing this information into a file format that I
MAL> can quickly search (sub second search time).
That would depend on exactly what you're searching for. Depending on just
how much data you're talking about, you could keep in-memory hashes or you
could use dbm files. A bonus to in-memory hashes is that you can store
complex data structures in them. You can do that with MLDBM, too, but you
get Data::Dumper and eval in the middle.
--
Jason L. Tibbitts III - tibbs@uh.edu - 713/743-8684 - 221SR1
System Manager: University of Houston High Performance Computing Center
1994 PC800 "Kuroneko" DoD# 1723
------------------------------
Date: 26 Mar 1997 14:03:33 -0600
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
To: mlehmann@prismnet.com (Mark A. Lehmann)
Subject: Re: PSCOPE - fast searching techniques
Message-Id: <ufaafnqpgiy.fsf@sina.hpc.uh.edu>
>>>>> "MAL" == Mark A Lehmann <mlehmann@prismnet.com> writes:
MAL> What I would like to do is search Perl code determining what
MAL> subroutines call other subroutines, where variables and object are
MAL> declared, where variables are assigned, and what files require or use
MAL> other files.
Well, the compiler has to do this for itself; it has the B::Xref tool which
generates a really big report about these things.
MAL> The other part is storing this information into a file format that I
MAL> can quickly search (sub second search time).
That would depend on exactly what you're searching for. Depending on just
how much data you're talking about, you could keep in-memory hashes or you
could use dbm files. A bonus to in-memory hashes is that you can store
complex data structures in them. You can do that with MLDBM, too, but you
get Data::Dumper and eval in the little.
--
Jason L. Tibbitts III - tibbs@uh.edu - 713/743-8684 - 221SR1
System Manager: University of Houston High Performance Computing Center
1994 PC800 "Kuroneko" DoD# 1723
------------------------------
Date: 26 Mar 1997 21:47:14 GMT
From: avm@best.com (Anthony Mulligan)
Subject: q
Message-Id: <5hc5h2$h5o$1@nntp2.ba.best.com>
------------------------------
Date: Wed, 26 Mar 1997 15:09:41 +0000
From: Aaron Bennett <abennett@stonehill.edu>
Subject: Re: Regular Expresion question.
Message-Id: <33393C2B.3C3E@stonehill.edu>
Aaron Bennett wrote:
Many many thanks for all the replies and gentle but constructive
criticism.
Of course, I had a syntax error: (boot to the head!)
> print "Content type: text/html", "\n\n";
> if %mail_form{'email'} =~ /\@{1}.+/ {
> print "<H1>Email is valid ", %mail_form{'email'}, "</H1>"; }
Syntactically should have read
print "Content type: text/html", "\n\n";
if ($mail_form{'email'} =~ /\@{1}.+/) {
print "<H1>Email is valid ", %mail_form{'email'}, "</H1>"; }
I'm a moron :) or at least a slow learner.
More importantly, many people explained to me the futility of attempting
to validate email addresses. I agree, I just want to put them through
some preliminary screening to trap obvious typos like
bennett@stonehilledu or bennett.stonehill.edu. So I settled on
m/@[^.@]+\.+/, which by looking for one or more @'s followed by any
character besided and @ followed by at least one period, should cut out
extremely obvious problems while allowing bizzare email address
conventions to pass through.
Thanks to all for the help and directional pointers.
--
| Aaron Bennett
| Internet Services Coordinator
| Stonehill College Department of Academic Computing
| http://www.stonehill.edu
| "The most precious things remain unseen."
------------------------------
Date: 26 Mar 1997 11:18:17 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: regular expression for check lower case
Message-Id: <5hbspp$bpq$1@halcyon.com>
In article <3338FF15.541@absyss.fr>, Douglas Seay <seay@absyss.fr> wrote:
|if you like slinging strings, you can use the lc() function
|to lowercase your string and then compare it to the original.
Whether you like slinging strings or not, you should do this, if
you care at all about your script working with more than the miniscule
number of languages (are there any?) within which [a-z] is all the
lowercase letters. lc takes into account locale-specific character
sets, regular expressions like [a-z] and [^A-Z] don't.
Brian
--
Brian L. Matthews Illustration Works, Inc.
For top quality, stock commercial illustration, visit:
http://www.halcyon.com/artstock
------------------------------
Date: 26 Mar 1997 19:32:07 GMT
From: bio4com@aol.com (Bio4com)
Subject: sendmail is killing program
Message-Id: <19970326193100.OAA04716@ladder01.news.aol.com>
I am using bulletin board program and I want to
send mail to some when a new message is posted
The script works great until I put in the group of lines
to sendmail. This exact group of text is used later on in
the program and works fine, is that maybe the problem?
The rest of the program actually runs but I still get the
internal error message
Thanks for the help.
Todd
$headTitle = "Ask The Dietician";
$bodyTag = "<body bgcolor=\"#FFFFFF\" text=\"black\" link=\"#0000FF\"
alink=\"#FFFF00\" vlink=\"#990000\">";
$bodyTitle = "<i><b><font size=5><font color=\"black\">ASK THE
DIETICIAN</font></font></b></i>";
$bbmDir = "/mnt/web/guide/bio4/bbm";
$SUBJCNT = "$bbmDir/bbmatic.cnt";
$TEMPLATE = "$bbmDir/bbmtemp.html";
$bbmUrl = "http://www.bio4.com/bbm";
$pinUrl = "$bbmUrl/ppin.gif";
$helpUrl = "$bbmUrl/bbmhelp.html";
$MAINPAGE = "/mnt/web/guide/bio4/bbm/bbmatic.html";
$mainUrl = "http://www.bio4.com/bbm/bbmatic.html";
$scriptUrl = "http://www.bio4.com/cgibin/bbmatic.cgi";
$mailCmd = '/usr/sbin/sendmail -t';
$myMail = "tnbohrer\@bio4.com"; # note mandatory backslash
$dateStamp = `/bin/date +"%D"`; chop ($dateStamp);
@badWords = ("hell","damn"); # use your imagination
##################################################################
# Read and parse Input from GET/POST
print "Content-Type: text/html\n\n";
if ($ENV{'QUERY_STRING'})
{ $buffer = $ENV{'QUERY_STRING'};
}
elsif ($ENV{'CONTENT_LENGTH'})
{ read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
@cgiPairs = split(/&/,$buffer);
foreach $cgiPair (@cgiPairs)
{
($name,$value) = split(/=/,$cgiPair);
$value =~ s/\+/ /g;
$value =~ s/%(..)/pack("c",hex($1))/ge;
$Form{$name} .= "\0" if (defined($Form{$name}));
$Form{$name} .= "$value";
}
##################################################################
# Case: NEW SUBJECT
if ($Form{'newsubject'})
{
if ($Form{'name'} && $Form{'email'} && $Form{'text'} &&
$Form{'subject'})
{
&validate
($Form{'name'},$Form{'email'},$Form{'text'},$Form{'subject'});
$subjCgi = $subject;
$subjCgi =~ s/ /\+/g;
# HERE IS THE OFFENDING "MODULE" IT
GIVES ME AN ERROR MESSAGE
open (MAIL, "|$mailCmd $mymail") || die;
print MAIL "From: $myMail\n";
print MAIL "Subject: $headTitle\n\n";
print MAIL "You have received a followup to your posting:\n";
print MAIL "\"$subject\".\n\n";
print MAIL "$text\n";
print MAIL "You can link directly to the BBS at -\n";
print MAIL "$mainUrl\n\n";
print MAIL "Thank You for making use of our resources at\n";
print MAIL "$headTitle\!\n";
print MAIL "Please bookmark us and visit frequently!\n";
close (MAIL);
# get subject ID nbr
open (COUNT,"<$SUBJCNT");
$subjNbr = <COUNT>;
if ($subjNbr =~ /\n$/) {chop ($subjNbr);}
close (COUNT);
$subjNbr++;
open (COUNT,">$SUBJCNT");
print COUNT "$subjNbr";
close (COUNT);
open (MAIN,"<$MAINPAGE");
@mainFile = <MAIN>;
close (MAIN);
# replace MainPage and insert new subject
open (MAIN,">$MAINPAGE");
$mainLine =0;
while ($mainLine <= $#mainFile)
{
if ($mainFile[$mainLine] =~ /<!-- next subject -->/)
{
print MAIN "<!-- next subject -->\n<hr>\n";
print MAIN "<font size=3><font
color=\"#FF0000\"><b>$subject</b></font></font><br>\n";
print MAIN "<font size=2 color=\"#000000\">Contributed By <a
href=\"mailto:$email\">$name</a> On
$dateStamp:</font> \n";
print MAIN "[ <a
href=\"$scriptUrl?subjnbr=$subjNbr&subject=$subjCgi&source=$email\"><font
size=2><b>Add Your Comment On This Subject</b></font></a> ]<br>\n";
print MAIN "<font size=2>$text</font><br>\n";
print MAIN "<!-- comment on $subjNbr -->\n"
} else
{ print MAIN "$mainFile[$mainLine]";
}
$mainLine++;
}
close (MAIN);
&message;
} else
{
print "ERROR: One or more required fields is blank.<br>\n";
&endIt;
}
} # END If NewSubject
------------------------------
Date: Wed, 26 Mar 1997 14:43:54 -0600
From: Eryq <eryq@enteract.com>
To: Bio4com <bio4com@aol.com>
Subject: Re: sendmail is killing program
Message-Id: <33398A8A.93AA025@enteract.com>
Without knowing the error message, the operating system, or
the Perl version, it's pretty impossible to give you
any help. :-(
Also, you'd make your life easier by using one of the standard
(and well-tested) Perl CGI modules (CGI.pm, CGI_Lite, or CGI::*).
These plus CGI::Carp are your friends.
Finally, you're much safer-off using:
open MAIL "|/usr/lib/sendmail -t -oi -oem" or die "sendmail: $!";
and piping a full message (complete with From:, To:, Cc:, etc. lines)
into it. Here's a thought: get a copy of MIME::Lite from
the CPAN, or off my web page... it's lightweight (nowhere near the
quality of Mail-Tools), but it'll let you assemble (and send, for Unixers)
a MIME-compliant message pretty painlessly.
Good luck,
--
___ _ _ _ _ ___ _ Eryq (eryq@enteract.com)
/ _ \| '_| | | |/ _ ' / Hughes STX, NASA/Goddard Space Flight Cntr.
| __/| | | |_| | |_| | http://www.enteract.com/~eryq
\___||_| \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
|___/ |______/ of the homeless: http://www.streetwise.org
------------------------------
Date: Wed, 26 Mar 1997 16:23:18 -0800
From: tucci@ar-tiste.com (Robert R. Tucci)
Subject: trivial perl question from an ignoramus
Message-Id: <tucci-2603971623180001@204.215.129.54>
Hi,
I'm trying to write a cgi in perl. Problem is, the amount of perl I know
could all be written on a postage stamp, with room to spare.
I found a simple perl subroutine on the web that is supposed to add prefix
zeros to integers< 10. Unfortunately, it doesn't work. Could someone
please tell me why?
This is what I'm doing:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$true_mon = $mon + 1;
&check($year, $true_mon, $mday, $hour, $min, $sec);
$x_inv_number = "$year$true_mon$mday$hour$min$sec";
#===============================================================
#Purpose of next sub: Add a 0 before any numbers < 10.
sub check
{
$i=0;
foreach $i (0 .. $#){
if($_[$i]<10){
$_[$i]="0$_[$i]";
}
}
@_;
}
#===============================================================
Bob Tucci
------------------------------
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 185
*************************************