[12972] in Perl-Users-Digest
Perl-Users Digest, Issue: 382 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 5 11:17:24 1999
Date: Thu, 5 Aug 1999 08:10:12 -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, 5 Aug 1999 Volume: 9 Number: 382
Today's topics:
Re: Question for Perl gurus (Bart Lateur)
Re: regexp can be your friend (Abigail)
Re: Regular expression for matching an e-mail address. (Anno Siegel)
sendmail <jkuhnert@harbingercomm.com>
Re: sendmail <kenhirsch@myself.com>
Re: Skipping . and .. with readdir <godot@clara.co.uk>
Re: Skipping . and .. with readdir (Abigail)
truncation without rounding ericp@us.ibm.com
Re: unus sed leo <tchrist@mox.perl.com>
Re: unus sed leo <tchrist@mox.perl.com>
Re: Useless error when {} unbalanced (Bart Lateur)
Re: Useless error when {} unbalanced (Bart Lateur)
Re: Useless error when {} unbalanced (Jerome O'Neil)
wait for process to die.. <qwerty@post.utfors.se>
Re: wait for process to die.. <tchrist@mox.perl.com>
Re: Why no Perl books at Fry's? (Abigail)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Aug 1999 13:10:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Question for Perl gurus
Message-Id: <37aa7784.21441182@news.skynet.be>
Mr Amigo21 wrote:
>I would like to know how we can open an external program
>via the Perl-CGI script to run on the server?
That question doesn't require guru level.
Bart.
------------------------------
Date: 5 Aug 1999 09:06:09 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: regexp can be your friend
Message-Id: <slrn7qj6hb.ucg.abigail@alexandra.delanet.com>
Bart Lateur (bart.lateur@skynet.be) wrote on MMCLXV September MCMXCIII in
<URL:news:37ad5693.13007722@news.skynet.be>:
<> Abigail wrote:
<>
<> >If my substring is 'foofoo', and the string is 'barfoofoofoobar', how
<> >many 'foofoo's does that contain? IMO, it contains 2 of them.
<>
<> >For overlapping, I fail to come up with a single RE
<>
<> How about:
<>
<> $_ = 'barfoofoofoobar';
<> $pattern = 'foofoo';
<>
<> /(?=$pattern).+?$pattern/;
<>
<> print "$`\n$&\n$'\n";
<>
<> ->
<> bar
<> foofoofoo
<> bar
<>
<> That doesn't replace, but it's a single regex.
Yeah, I thought of that later. You don't really need the ?. And
here's how you do replacement:
$str = quotemeta $substring;
s/(?=.+$str)$str/replacement/s;
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 5 Aug 1999 13:21:11 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regular expression for matching an e-mail address.
Message-Id: <7oc347$e77$1@lublin.zrz.tu-berlin.de>
Keywords: Hexapodia as the key insight
revjack <revjack@radix.net> wrote in comp.lang.perl.misc:
>Makarand Kulkarni explains it all:
>:[Daniel Doreika wrote..]
>:> Can someone please provide me with
>:> the best possible regular expression for matching an e-mail address?
>
>:The Regular Expression is
>:/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/
>:I will leave it to you to decide if this is the best one.
>
>Here we go again. :)
>
>Has anyone ever typed in Jeffrey Friedl's monster regex, so we can point
>the questioner to it on the web, like Abigail's regex for URLs? That
>should drive the point home.
http://enterprise.ic.gc.ca/~jfriedl/regex/email-opt.pl
Anno
------------------------------
Date: Thu, 5 Aug 1999 10:15:29 -0700
From: "G. Kuhnert" <jkuhnert@harbingercomm.com>
Subject: sendmail
Message-Id: <37a99bf5.0@news.kivex.com>
I know that the subject has been talked to death, but I have been unable to
solve one minor little problem. If I knew of some other source for help I
would certainly go to it, so as not to waste any more time than need be. I
know about the Perl Journal, but have not had the resources to subscribe
these paste few days. I have gone to perl.com, webdeveloper.com, read
various man pages, etc....Basically, I have done my homework, and am
confident that my script should work, but for some reason I think that it
may be the server's fault. I am just trying to send test e-mail using a
UNIX sendmail server. Following is the script:
#! usr/local/bin/perl
print"Content-type: text/plain\n\n";
$from = "nobody\@hotmail.com";
$name = "nobody";
$to = "jkuhnert\@harbingercomm.com";
$subject = "Testing!!!";
$body = "Hello, does this work??";
$errors = "jkuhnert\@harbingercomm.com";
open (SENDMAIL, "| /usr/lib/sendmail -t -n");
print SENDMAIL <<End_of_Mail;
From: $from <$name>
To: $to
Reply-To: $from
Errors-To: $errors
Sender: $from
Subject: $subject
$body
End_of_Mail
close(SENDMAIL);
The server error-log states the following when run:
Apache: Premature end of script headers blah/blah./../cgi-local/mailsend.pl
I have confirmed, and reconfirmed the paths to everything with the server
company. They did say that they don't allow "Telnet" 'ing . Is there
anything here that jumps out as being a problem to anyone?
Any help is of course, greatly appreciated.
George
P.s. I have also tried using CGI module w/ the following code, and get the
same error. Which, by the way, was copied and pasted directly from one of
them many examples that I've found.:
#!/usr/local/bin/perl
use CGI;
my $query = new CGI;
my $sendmail = "/usr/lib/sendmail -t";
my $reply_to = "Reply-to: foo@bar.org";
my $subject = "Subject: Confirmation of your submission";
my $content = "Thanks for your submission.";
my $to = $query->param('to');
# my $file = "subscribers.txt";
unless ($to) {
print $query->header;
print "Please fill in your email and try again";
}
# open (FILE, ">>$file") or die "Cannot open $file: $!";
# print $to,"\n";
# close(FILE);
my $send_to = "To: ".$query->param('to');
open(SENDMAIL, "| $sendmail") or die "Cannot open $sendmail: $!";
print $reply_to;
print $subject;
print $to;
print "Content-type: text/plain\n\n";
print $content;
close(SENDMAIL);
print $query->header;
print "Confirmation of your submission will be emailed to you.";
------------------------------
Date: Thu, 5 Aug 1999 10:38:51 -0400
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: sendmail
Message-Id: <7oc7p6$4fi$1@oak.prod.itd.earthlink.net>
G. Kuhnert <jkuhnert@harbingercomm.com> wrote:
> #! usr/local/bin/perl
This is the first thing that stands out.
Shouldn't there be a slash in front of "usr/local/bin/perl"
First make sure that you can run ANY perl program:
#!/usr/local/bin/perl -w
print"Content-type: text/plain\n\n";
print "This worked";
Then see if there's a problem with sendmail (although the error log
indicates more serious problems):
> open (SENDMAIL, "| /usr/lib/sendmail -t -n");
You didn't check for errors here
> close(SENDMAIL);
or here.
------------------------------
Date: Thu, 05 Aug 1999 14:27:11 +0100
From: Del Kennedy <godot@clara.co.uk>
Subject: Re: Skipping . and .. with readdir
Message-Id: <37A9912F.EAC7180@clara.co.uk>
............................
>
> --
> Dave Guertin
> guertin@middlebury.edu
This is the way the cookbook suggests, and it works for me:
> while ( defined ($next_c = readdir DIRECTORY))
> {
next if $next_c =~ /^\.\.?$/; # skip . and ..
dostuff;
}
Del Kennedy
Rural Radio Systems
dmk@rayleigh.ecs.soton.ac.uk
------------------------------
Date: 5 Aug 1999 09:36:06 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Skipping . and .. with readdir
Message-Id: <slrn7qj89h.ucg.abigail@alexandra.delanet.com>
David Guertin (guertin@middlebury.edu) wrote on MMCLXIV September
MCMXCIII in <URL:news:x6i907r1r4e.fsf@caddis.middlebury.edu>:
;;
;; while ($_ = grep !/^\.\.?$/, readdir (INPUT_DIR)) {
;; dostuff;
;; }
;;
;; But this syntax is screwed up in a way that I don't understand. Can
;; someone please help me put this grep into a while function in a way
;; that works?
No. That's the wrong question. You do not want to put the grep in
while. The example you based your code on assigns to an array. You
assign to a scalar. Did you try to look up the behaviour of grep
in scalar context? Did you try to look up what grep does to the
context of its arguments?
The answer to the question "how do I skip `.' and `..'", is:
while ($_ = readdir (INPUT_DIR)) {
next if /^\.\.?$/;
...
}
or
while ($_ = readdir (INPUT_DIR)) {
next if $_ eq "." || $_ eq "..";
...
}
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 05 Aug 1999 13:47:37 GMT
From: ericp@us.ibm.com
Subject: truncation without rounding
Message-Id: <7oc4ll$9q3$1@nnrp1.deja.com>
I'm writing a CGI script for calculating a golfers handicap. The number
produced has to be truncated to the tenths without rounding. I know
that both printf() and sprintf() will round the last digit, so how do I
make it NOT round?
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 5 Aug 1999 07:57:38 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: unus sed leo
Message-Id: <37a99852@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Chris Goodwin <archer7@mindspring.com> writes:
:Mr. Clark has been known to deliberately give himself short deadlines
:in order to save work.
I was at a talk by Garrison Keillor (oburl=> http://phc.mpr.org/) in which
he related how we wrote his Lake Wobegone monologue. Twenty-four hours
before air time, he has not a word written. He says it's like every
Friday afternoon learning that you have a final the next night for a
class you forgot you'd signed up for. I just kept thinking about how
well it is said to focus the mind to know you'll be hanged in the morning.
--tom
--
"No problem is so formidable that you can't walk away from it."
--C. Schulz
------------------------------
Date: 5 Aug 1999 08:43:03 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: unus sed leo
Message-Id: <37a9a2f7@cs.colorado.edu>
[REPOST -- this appears to have been mysteriously cancelled]
That took three minutes to propagate from thee to me. What
is the world coming to?
In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
:> "Unus sed leo", says the lioness, meaning "One, but [it is] a lion."
:
:How very clever of the animals in Aesop the Greek's fables to speak
:Latin!
Ah, but I've no Greek to read it thus.
Here's a more extensive quote from The Latin Reader at
http://www.slu.edu/colleges/AS/languages/aes-h.html
Vulpes et Leaena.
Vulpes leaenam exprobrabat, quod non nisi unum catulum
pareret. Huic dicitur respondisse, unum, sed leonem.
Which just goes to show you that vulpine exprobration of lions is
not always going to elicit the answer one was hoping for.
Apparently the Romans so appreciated the sentiment that they took the
phrase to heart and have gone on repeating it as a standard catch-phrase
for the next couple millennia, even after they decided that the name of
their tongue was no longer Latin, but Italian. Search for it and you'll
come up with some odd and interesting things, like this
http://rai-enac.it/volabilita/precedenti/35-36/art08.htm
One more lion bit: I've recently heard tell that the lions of Greece
and Asia Minor had no great manes as have their African cousins due
to a lack of hyenas to apply evolutionary pressure to let develop such
large protective neckware. Apparently this is the African male lions'
main/mane job.
:Indeed. And then if anything useful (like Unix or C, for example)
:emerged, they threw it over the wall to my lab, where scores of non-
:lions (drones, I see you call them) did source control, documentation,
Actually, the drones in the tales told to me were sometimes rather more
of the mainframe dataprocessing flavor.
:(ObPerl: vide Perl!)
I was thinking that, too, but didn't think "vide margaritam" would come
out as trippingly.
--tom, who hopes that one can infer the appropriate emoticons peppered
throughout this overly late-night posting of supersillinesses.
--
"Most Non-Unix managers conclude that VI is either extraterrestrial
in origin or was devised by the original Unix developers as part of a
secret communication s code to reach another dimension."
--Communications Week - July 26, 1993.
------------------------------
Date: Thu, 05 Aug 1999 13:11:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Useless error when {} unbalanced
Message-Id: <37ad78ed.21802039@news.skynet.be>
Abigail wrote:
>And if you read Filips question, you see his problem was a missing {,
>not a missing }.
Huh? He wrote:
| But boy you miss a } and you're screwed
Bart.
------------------------------
Date: Thu, 05 Aug 1999 13:11:04 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Useless error when {} unbalanced
Message-Id: <37ac78b0.21741182@news.skynet.be>
Filip M. Gieszczykiewicz wrote:
>URGH! The longer my scripts get, the more annoying the perl error for
>unbalanced {} is getting. Missing { is informative:
>
>Unmatched right bracket at /tmp/mkHOME.pl line 103, at end of line
>But boy you miss a } and you're screwed:
>
>Missing right bracket at /tmp/mkHOME.pl line 1778, at end of line
>syntax error at /tmp/mkHOME.pl line 1778, at EOF
You can snip out, or comment out, (the contents of) whole blocks that
you think are suspect (= the newer blocks). Once you can get it to match
again, you've found your problematic block. Now narrow it down...
Bart.
------------------------------
Date: 5 Aug 1999 14:46:09 GMT
From: jeromeo@atrieva.com (Jerome O'Neil)
Subject: Re: Useless error when {} unbalanced
Message-Id: <7oc83h$7td$1@brokaw.wa.com>
In article <9gaq3.312$LM2.3243@news13.ispnews.com>,
pacman@defiant.cqc.com (Alan Curry) writes:
> Then I go up and fill in the middle part. Now I never have mismatched braces.
> If I'm going to quit coding for the day, or even for just a few minutes, I
> put a little bit of uncompilable garbage in the empty block just to be sure I
> won't forget to fill it in later.
I always try to leave incomplete blocks in a compilable state. I don't
know why, perhaps I'm just retentive. Your method makes sense, though.
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.i-filezone.com
------------------------------
Date: Wed, 04 Aug 1999 15:42:03 +0200
From: "Dr. Who" <qwerty@post.utfors.se>
Subject: wait for process to die..
Message-Id: <37A8432A.18EA7ED9@post.utfors.se>
how do I wait for a process to die?
ex:
system("lynx http://localhost/file.html -source > outfile");
print "Don't print this until lynx-process has terminaded";
..if anyone know? :)
------------------------------
Date: 5 Aug 1999 08:06:49 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: wait for process to die..
Message-Id: <37a99a79@cs.colorado.edu>
[courtesy copy mail to cited author]
In comp.lang.perl.misc, "Dr. Who" <qwerty@post.utfors.se> writes:
:how do I wait for a process to die?
:
:system("lynx http://localhost/file.html -source > outfile");
:print "Don't print this until lynx-process has terminaded";
You just did! That's what system is. fork and exec and wait.
--tom
--
"Mediocrity is a hand rail."
- Baron de Montesquieu
------------------------------
Date: 5 Aug 1999 09:18:27 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Why no Perl books at Fry's?
Message-Id: <slrn7qj786.ucg.abigail@alexandra.delanet.com>
Paul (paul@mccombes.demon.co.uk) wrote on MMCLXIV September MCMXCIII in
<URL:news:l7aBbDAtZJq3EwDh@mccombes.demon.co.uk>:
:: In article <slrn7qf1ab.s67.abigail@alexandra.delanet.com>, Abigail
:: <abigail@delanet.com> writes
:: >
:: >Lecture Notes in Computer Science; Springer Verlag. They also have a
:: >yellow wall, for their Math series. Yellow and grey walls are usually
:: >found in academic libraries, although there's at least one book shop in
:: >London (I can't remember the name, but I sure will be able to find it)
:: >that does have a grey wall.
:: >
:: Probably Foyle's in Charing Cross Road, as (a) it has a huge academic
:: stock and (b) it displays by publisher (even in the fiction department).
Indeed, it is.
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
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 382
*************************************