[9328] in Perl-Users-Digest
Perl-Users Digest, Issue: 2923 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 20 20:07:17 1998
Date: Sat, 20 Jun 98 17:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 20 Jun 1998 Volume: 8 Number: 2923
Today's topics:
Re: ?CGI scripts & Explorer (-)
Re: ?CGI scripts & Explorer (Michael Rubenstein)
Re: ?CGI scripts & Explorer (Larry Rosler)
Re: Error log processing (-)
Re: first language birgitt@my-dejanews.com
Re: first language (John Beppu)
Re: first language <tjurik_NoSpam_@li.net>
Re: first language <tjurik_NoSpam_@li.net>
Re: first language (Larry Rosler)
Re: Flames.... (T. Ames)
Re: mail script w/ attachments (-)
Re: Newbie print << question (Rob Hindle)
Re: Newbie print << question (Brian McIntosh)
Re: Newbie print << question <*@qz.to>
Re: Printing E-Mail to a file (-)
Qustion for contract Perl scripters <fistful@pacbell.net>
Re: REVIEW: Perl CGI Programming - No Experience Requir (Rahul Dhesi)
Re: Sending file with Perl Script (Mark Thompson)
Re: Sort problems <dean@mail.biol.sc.edu>
Re: Subtracting Number of seconds from a date (-)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Jun 1998 22:09:28 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: ?CGI scripts & Explorer
Message-Id: <358c2911.41812229@news2.cais.com>
miker3@ix.netcom.com (Michael Rubenstein) Said this:
>
>Actually, I did not intend that as a swipe at the "upgrade your perl"
>responses we often see here. Perhaps they do go a bit far in
>expecting everyone to always keep up with minor upgrades (though I
>have a "latest version" fetish and do so), but it is a completely
>reasonable response to those who have problems with version 4. There
>has to be a limit on support for old versions.
>
>My point was the opposite -- that it is reasonable for Microsoft (or
>any other company) to refuse to fix bugs in an older version when a
>newer one is available. Microsoft has a lot to answer for, but not
>everything they do is wrong.
I disagree. They should support everything they publish, within a
reasonable limit, obviously. I mean, I don't expect microsoft to
still support MS-DOS 2.0 or anything, but if there is a significant
number of customers still using win 3.1, then they should support that
version. I mean, let's consider reality here. While lots and lots of
people will jump all over windows 98, since it's "new" and it's the
latest version, and well, we gotta have whatever is the newest
thing... or perhaps they have some mistaken idea that windows 95 will
stop working after windows 98 is released? I mean.... well, if you
follow the industry as closely as I do, you'll realize that 90% of
corporate IT managers surveyed reported that they had absolutely NO
intentions of upgrading to windows 98. They felt no compelling need
to put their organization through the turmoil and expense of what
amounts to a minor upgrade, when they've all grown accustomed to the
windows 95 environment. I mean, it's only been about a year at most
since many companies finally worked through all the growing pains of
the switch to 95, why put themselves through that all over again? An
operating system is merely a way to get their applications running, so
that their employees can get their work done. They don't care about
trivial things like "integrated web browsing" and support for USB
serial devices, or whose testosterone level is higher than the other
guy's. "Mine is bigger than yours" is not a valid corporate IT
philosophy, at least not officially. So if the computers are working,
and employees can get to their files, write reports, create proposals,
run their spreadsheets and whatever else they need to do, why break
what ain't fixed? Yes, I know I transposed that, it's funnier that
way, go with it.
Now, this is where microsoft can either rise to the challenge or shoot
itself in the foot. If the majority of the business consumers choose
to stick with 95 for all sorts of reasons (cost, reliability,
compatibility with existing apps, etc) and microsoft refuses to
address issues that come up in windows 95, then these business
consumers will grow tired and frustrated with microsoft. What
microsoft does not need at the moment is bad blood between them and
their customers. Believe me, people feel like they are stuck with
microsoft now, but if they get pushed far enough, they will eventually
realize that they really aren't stuck with ms, that there are
alternatives. And they will head straight to the alternatives
immediately.
Like I mentioned in my first post, look at Novell as an example. They
continue to support Netware 3.12 because there are significant amounts
of working 3.12 servers out there, and to alienate those customers is
suicide. Sure, they could go after a quick buck by telling every 3.12
customer "hey, sorry you're having problems, but if you want any help
you're going to have to shell out some dough for the newer version.
And we don't care if you CANNOT use the newer version with existing
legacy systems". (the Coast Guard and those that need to connect to
sabre cannot use 4.11 to connect to these systems, they need 3.12 (and
2.2) to do this)
I mean, if you track user-agents in your web server logs, you'll see
that of the three commonly used versions of IE (2.x, 3.x and 4.x), 3.x
has the most significant numbers. I show 2.x at about 5 or 6% (of all
browsers, not just IE browsers), 3.x with a 22% share, 4.x with about
a 9 - 11% share. So, let's say that all explorer versions combined
have a 37% market share, and of that, over HALF is explorer 3.0. Now,
some of those users may just be lazy and don't feel like upgrading,
but some may have external limitations (company mandates, hardware
incompatibilities, whatever) that prevent them from upgrading to 4.0.
So, by refusing to address any problems with 3.0, microsoft is saying
"fuck you" to almost half of their explorer customers.
As for your problems with perl4, I'm sure you can find fixes to many
bugs. Whether or not they are actively supporting perl4 or not is a
non-issue, unless of course there are significant numbers of people
still using and developing programs for perl4. If there are
significant numbers of perl4 users and they are not actively fixing
bugs that crop up, this doesn't support your position in any way,
unless of course the perl developers are in some way responsible for
setting the "code of conduct" in the software industry... if they
aren't supporting an actively used product, they too are wrong, and
they too should provide support for this "older" version just like
microsoft should support IE 3.0.
------------------------------
Date: Sat, 20 Jun 1998 22:49:15 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: ?CGI scripts & Explorer
Message-Id: <35933c3a.15487079@nntp.ix.netcom.com>
On Sat, 20 Jun 1998 22:09:28 GMT, root.noharvest.\@not_even\here.com
(-) wrote:
>So, by refusing to address any problems with 3.0, microsoft is saying
>"fuck you" to almost half of their explorer customers.
No doubt this explains why Microsoft is having so much trouble selling
their products.
--
Michael M Rubenstein
------------------------------
Date: Sat, 20 Jun 1998 16:19:37 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: ?CGI scripts & Explorer
Message-Id: <MPG.ff5e3641a764d7c9896b0@nntp.hpl.hp.com>
In article <358c2911.41812229@news2.cais.com>,
root.noharvest.\@not_even\here.com (-)
<root.noharvest.\@not_even\here.com (-)> says...
You have some interesting thoughts, name-less, organization-less and
signature-less one with a bogus e-mail address. Just as newspapers
reject anonymous letters, I won't participate in a dialogue with a
phantom. Too bad...
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Jun 1998 22:57:03 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Error log processing
Message-Id: <358c3da3.47071228@news2.cais.com>
"Asbjorn Gjemmestad" <agjemmes@virtualis.com> Said this:
>A while ago I saw a posting on this group about a script taking the last
>ten lines of your error log and displaying them. Does anyone know where I
>can get a hold of this script?
>
The easiest way, although it's not "portable" (meaning you really
shouldn't use NT) is to use tail, an external unix program:
$lines = `tail -10 $filename`;
or pipe it like this:
`tail -10 $filename >temp.txt`;
open (IN, "temp.txt");
while (<IN>)
{
&DoSomething;
}
close IN;
------------------------------
Date: Sat, 20 Jun 1998 22:25:16 GMT
From: birgitt@my-dejanews.com
Subject: Re: first language
Message-Id: <6mhcsc$rrl$1@nnrp1.dejanews.com>
In article <6mgh0j$6o9$1@supernews.com>,
snowhare@devilbunnies.org (Snowhare) wrote:
>
>
>
> Nothing above this line is part of the signed message.
>
> In article <6me68f$ijt$1@client3.news.psi.net>,
> Abigail <abigail@fnx.com> wrote:
> >That sounds as if programming would be an art. I disagree with that.
> >I believe that most people can be able to learn how to program. Just
> >like most people could learn how to become a car mechanic.
> >
> >Whether everyone has the motivation to learn is a different issue.
>
> You've stepped right into one of the oldest debates in programming.
> I am on the programming as an art side. I can teach a person all
> about the abstractions, the techniques, the theory and practice -
> but I can't give them the 'spark' that is the difference between
> what I'll call a 'cookbook' programmer and a 'chef' programmer.
The same is true for any field which requires creativity and design,
music composition, architecture, literature, visual arts.
Just because the creative work is done with tools which
require a high degree of logic, mathematics and precision, I think
the creative design part is similar to any other creative work.
You either are one of the rare talents who have this gift or you
don't. Which, I believe, doesn't and shouldn't mean that if you
don't, you can't learn how to program and become a decent, acceptable,
professional programmer.
Wouldn't be our schools of art, music and literature be empty, if
you would tell each student who decides to learn the tools, which
are the prerequisites to eventually create their first pieces of art
(of whatever quality): "No, please don't bother to learn, you have
to be a born artist. And there are only a handful who are."
I also see a difference between the product a programmer
and an artist (painter, musician) creates. The quality of a
program can objectively be measured by how flawless and
functional it works for the purpose it was designed. I am not
sure how you measure a piece of art like a painting.
Birgitt Funk
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 20 Jun 1998 22:40:58 GMT
From: beppu@rigel.oac.uci.edu (John Beppu)
Subject: Re: first language
Message-Id: <6mhdpq$c4n@news.service.uci.edu>
In article <odPi1.3807$RS.3390143@news3.atl.bellsouth.net>,
Judson McClendon <judmc123@bellsouth.net> wrote:
>Cyrand wrote:
>>
>>As a novice programmer, ...
><snip>
>>I was nervous about using pointers, and so had trouble using them
>>the first few times. After a few uses, I realized that they were
>>more useful than they said, and less tricky.
><snip>
>
>There is a real connection here. If you don't think C pointers are
>'tricky', it just means you haven't used them enough to be bitten by
>their subtleties. :-)
>--
I feel like putting in my own 2 yen here.
I am of the opinion that the best way to become familiar with
pointers is to learn an assembly language of the architecture
you use most often. I knew x86 assembly before I knew C, but
moving to C from assembly was not a problem. A lot of times,
I found myself thinking, "this is kinda like assembly" while
learning C.
If I ever taught anyone to program, I'd get some Assembly in
early on to harden them and make them fearless. ;)
--
/** beppu@uci.edu ......................................................... */
------------------------------
Date: Sat, 20 Jun 1998 19:08:00 -0400
From: "T Jurik" <tjurik_NoSpam_@li.net>
Subject: Re: first language
Message-Id: <6mhfcc$k4q$1@news01.li.net>
Deva Seetharam wrote in message <358AA28C.1882F4F9@execpc.com>...
>
>
>"programming" and "Programming" are not the same.
>Point is not whether somebody can learn to write a few lines of code;
>But whether he/she can use the programming lang. to solve a real world
problem
>efficiently, elegantly and **effectively**.
>
>Programming is undoubtedly an art.
>It requires a brilliant mind to understand the problem domain,
conceptualize
>a suitable data structure and employ an efficient algorithm to produce
>an elegant solution.
I do not think Programming or programming is an "art." It does not require
a brilliant mind to do any of what you described. Also, good programming
and design can be learned. Very good programmers do not have higher
intelligence than other people in professional positions. One must be
rigorous in one's thinking, yes, but this is not an art, nor is it
brilliance.
Most programmers will never really have to solve totally unique problems.
An understanding of what has been done already, how to do it and how to
apply the solved problems to one's domain is all that is really needed.
Granted, this is not what most programmers like to hear.
Tim
------------------------------
Date: Sat, 20 Jun 1998 19:01:09 -0400
From: "T Jurik" <tjurik_NoSpam_@li.net>
Subject: Re: first language
Message-Id: <6mhevk$jrp$1@news01.li.net>
Larry Rosler wrote in message ...
>In article <6mbktf$5qp$1@msunews.cl.msu.edu>, nguyend7@egr.msu.edu
>says...
>...
>As one of the first who tried to teach C many years ago, I can vouch that
>it is a poor choice for beginners, for one spcific reason that is seldom
>discussed: the difficulty of doing simple text input with data
>conversion.
This depends on the reason the 'beginner' is learning the language. If one
is using the language primarily for simple tasks with a good deal of user
input or other such work, then C is probably not the way to go. Teaching C
within the contect of other computer science courses is fine. C then
becomes the language with which one expresses the concepts one is learning.
(A previous poster mentioned Abelson and Sussman's excellent book. One of
reasons that this is such a good book is that it does not focus on the
language as much as other books such as the tree-killing 'teach yourself
<Some Language> in <N> days. )
One of the probelems with 'learning a languege' is the implied need to learn
how to program. This is the real reason (In my opinion) that most books
fall short and only serve to increase the number of people on this planet
who know some language syntax or enter obfuscated language contests.
A good example of this idea is what you write below regarding learning
regular expressions from Sed and Awk. (Mr. Nguyen also stated something
similar.) regular expressions are not unique to languages like perl, Awk
and Sed. Rather they are a language of defining patterns, etc. and regular
expressions are a part of every decent computer science curriculum that I
know of.
>
>Once one gets past single-character input (getchar or getc) or perhaps
>line-at-a-time-and-parse-it-yourself input (gets or fgets, atoi, atof,
>...), one encounters the horrible scanf function, which demands an
>understanding of pointers and internal representations. Fuggedaboudit!
>
>C++ is better on input conversions, and Perl can rely on text isolation
>via regexes and automatic conversions. Regexes are hard unless one has
>been weaned on ed/vi/grep/awk/sed/... but the student must learn them
>right away to get much useful work done anyway. But Perl references can
>wait till much later, while C pointers cannot.
>
>Don't teach C to beginners!
I agree here -- only insofar as using C++, Smalltalk, Scheme, or Java rather
than C. One should try to teach 'beginners' as many languages as possible.
Using the right tool (language) for a particular problem/job is a
significant help in creating a solution.
Tim J
------------------------------
Date: Sat, 20 Jun 1998 16:42:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: first language
Message-Id: <MPG.ff5e8a7393af52f9896b1@nntp.hpl.hp.com>
In article <6mhdpq$c4n@news.service.uci.edu>, John Beppu
<beppu@rigel.oac.uci.edu> says...
...
> I am of the opinion that the best way to become familiar with
> pointers is to learn an assembly language of the architecture
> you use most often. I knew x86 assembly before I knew C, but
> moving to C from assembly was not a problem. A lot of times,
> I found myself thinking, "this is kinda like assembly" while
> learning C.
Maybe I can dig up some old papers in which I describe C as a "portable
assembly language." This is because the basic abstraction is at the bits
and bytes level: bit-fields and unions and such, with all the baggage
including byte ordering out there to touch and feel.
> If I ever taught anyone to program, I'd get some Assembly in
> early on to harden them and make them fearless. ;)
At the risk of sounding like one of those old geezers who says, "That's
the way I learned, and it was good enough for me, so it should be good
enough for you.", that's the way I learned, and it was good enough for
me, so it should be good enough for you. :-)
LR>Summary:
LR>My *real* choice for a first language for students who want to become
LR>"real" (i.e., professional) programmers would be an abstract assembly
LR>language such as MIX (Knuth, vol. 1).
MJD>That is very interesting. I am skeptical, but I am very eager to
MJD>hear you recount your experiences if you have actually done that.
Sample of one, unfortunately. My kids started with Basic, which (as
Dijkstra says) is a terminal disease. They are *not* professional
programmers. :-)
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Jun 1998 22:44:39 GMT
From: ames0009@tc.umn.edu (T. Ames)
Subject: Re: Flames....
Message-Id: <358c35a7.837222@news.tc.umn.edu>
On 20 Jun 1998 19:09:04 GMT, Tom Christiansen <tchrist@mox.perl.com>
wrote:
>grep. man -k. less. find. whatever.
>
>If you haven't figured out how to search for things,
>turn off your computer until you can buy yourself
>a pet trainer.
>
>--tom
This is exactly the kind of response that the original poster was
addressing. You are assuming that someone new to Perl and new to this
newsgroup (for those are the people who would post a simple question
or a question that is answered in the FAQ) already knows a) what
"grep" is and b) how to use it.
Your response also displays the "I'm so smart--you're so stupid"
attitude that does no one any good. I don't mean to single you out;
this attitude is very common among programmers. We are dealing with
programmers of all levels here, and everyone should keep in mind that
what is so painfully obvious to the advanced programmer is often
cryptic to the newbie. That is why the newbie is asking the question:
if they knew how to find the answer I assume they wouldn't ask someone
else or post to this newsgroup at all.
The only real solution to this problem is to have a moderated group
AND a non-moderated group. That way, those who refuse to show some
tolerance for FAQable questions can simply stick with the moderated
group -- and those who are willing to help out the more desperate
beginners can also address the questions in the non-moderated group.
We all want the language to flourish -- with two newsgroups it could
continue to grow without so many headaches.
T. Ames
>>>>>>>>>>>>>>>>>>>
Todd C. Ames
ames0009@tc.umn.edu
University of Minnesota
------------------------------
Date: Sat, 20 Jun 1998 22:29:54 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: mail script w/ attachments
Message-Id: <358c3731.45425481@news2.cais.com>
Jim Bowlin <bowlin@sirius.com> Said this:
>rferr wrote:
>>
>> Does anyone know how to invoke sendmail with attachments ? I have the cc:,
>> bcc:
>> down but attachments is eluding me.
>> Thanks.
>
>I wrote a module that can send attachments. It uses Net::SMTP which
>bypasses sendmail. You could modify it to use sendmail if you really
>wanted to, but it might be better to use it as is if you have an
>SMTP host to send the email to. I can have it email itself to you.
>
You wouldn't happen to know how to do the reverse, would you? I'm
trying to set up my .forward file to use a "filter" that will include
the ability to decode attachments (not all, just in messages that get
filtered in some way, like to grab report files from a distributor, or
whatever), The only problem is it needs to be able to handle the
common encoding methods, not just uuencode, but BinHex and Mime as
well)
(if you email me privately, my address is webmaster @ lmnet . com -
I'm very tired of spam, so I'm really paranoid about putting my email
address in a usenet message.)
------------------------------
Date: Sat, 20 Jun 1998 22:31:05 GMT
From: Sheffield@hndl.demon.co.uk (Rob Hindle)
Subject: Re: Newbie print << question
Message-Id: <358f3763.22691055@NEWS.DEMON.CO.UK>
A reply from another Perl newbie who struggled with something very
similar!
My problem was it seems unhappy to see spaces before the final
RESULTS-HEADER. I didn't use quotes around the first instance of
RESULTS-HEADER, maybe that's relevant.
--
Rob.Hindle@hndl.demon.co.uk
On Sat, 20 Jun 1998 19:36:16 GMT, brian_mcintosh@csi.com (Brian
McIntosh) wrote:
>I am taking my first steps down the perl road, and have attempted to
>load a perl CGI scrip on my server and execute it.
>
>When I run then script, I get the following error:
>
>Can't find string terminator "RESULTS-HEADER" anywhere before EOF at
>query.pl line 60.
>
>Line 60 shows this:
>
>print <<"RESULTS-HEADER";
><HTML>
><HEAD>
><TITLE>Contact-Information Search Results </TITLE>
></HEAD>
><BODY BGCOLOR="#FFFFFF">
><H1> Contact-Information Search Results</H1>
>RESULTS-HEADER
>
>I have tried a few different syntax changes at line 60 based on some
>messages in this newsgroup, but have not been able to get this sorted
>out.
>
>Any suggestions where I should begin to look?
>
>Thanks,
>
>Brian McIntosh
------------------------------
Date: Sat, 20 Jun 1998 23:27:34 GMT
From: brian_mcintosh@csi.com (Brian McIntosh)
Subject: Re: Newbie print << question
Message-Id: <358c449a.2770992@news.compuserve.com>
On Sat, 20 Jun 1998 22:31:05 GMT, Sheffield@hndl.demon.co.uk (Rob
Hindle) wrote:
>A reply from another Perl newbie who struggled with something very
>similar!
>My problem was it seems unhappy to see spaces before the final
>RESULTS-HEADER. I didn't use quotes around the first instance of
>RESULTS-HEADER, maybe that's relevant.
I have tried quotes/no-quotes, and I still get the error. I have no
spaces between the final RESULTS-HEADER. Is there a limit on
characters, or the use of '-'?
I am using the following version of Perl on my ISPs machine.
This is perl, version 5.003 with EMBED
built under linux at Jun 27 1996 21:52:16
+ suidperl security patch
Any other suggestions???
Brian
------------------------------
Date: 20 Jun 1998 23:46:28 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Newbie print << question
Message-Id: <eli$9806201940@qz.little-neck.ny.us>
In comp.lang.perl.misc, Brian McIntosh <brian_mcintosh@csi.com> wrote:
> Sheffield@hndl.demon.co.uk (Rob Hindle) wrote:
> >My problem was it seems unhappy to see spaces before the final
> >RESULTS-HEADER.
You cannot have spaces before *or* after the end of text marker.
> >I didn't use quotes around the first instance of
> >RESULTS-HEADER, maybe that's relevant.
> I have tried quotes/no-quotes, and I still get the error. I have no
The use of quotes will change the way it is interpolated. No quotes
or "double" quotes are treated like a normal "double" quoted string.
'Single' quotes are treated like a 'single' quoted string. 'Back'
quotes are treated like a 'back' quoted string.
> spaces between the final RESULTS-HEADER. Is there a limit on
> characters, or the use of '-'?
The '-' is fine, check for trailing spaces or tabs on the RESULTS-HEADER
line.
Elijah
------
upgrade your perl: 5.003 has security holes
------------------------------
Date: Sat, 20 Jun 1998 22:50:05 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Printing E-Mail to a file
Message-Id: <358c395f.45979179@news2.cais.com>
Jesse Rosenberger <jesse@savalas.com> Said this:
>does anyone know of a script that can read e-mail from a POP3 account
>and if the subject *begins* with a certain word, such as "PERL - " (but
>might have other words after it), it would read the message body, and
>print it to a file? If no one knows of a script...maybe a similiar
>script that I can modify to suit my needs? thanks in advance to anyone
>who can help. Oh, and I would prefer if the method of going about it
>didn't require a module because I have no way of installing them at this
>point because I only have FTP access...and not any telnet. thanks again.
>
>Jesse Rosenberger
>
The simplest way, absent of installing all kinds of modules and trying
to figure it all out, is to use a simple "filter" script that is
called by .forward (a file in your home directory) every time sendmail
recieves a message to that user.
This is an example of the .forward file:
"|~/mailfilt"
one simple line, tells sendmail to pipe the email message to a program
in your home directory called "mailfilt".
Here's the top half of mailfilt:
#!/usr/bin/perl
$header = '';
$body = '';
while (<>) # Get headers
{
last if /^$/;
push(@headers, $_);
$header .= $_;
($field, $value) = /^(\S*)\s*(.*)/;
if (length($field) > 1) { $fields{$field} = $value; }
else { $fields{$field} .= " $value"; }
}
while (<>) # Get body
{
$body .= $_;
}
-----------------------------------------
Now, what happens is sendmail pipes the new message as it arrives to
mailfilt. Mailfilt takes the message and breaks it into a hash of the
headers and puts the body of the message in the variable $body.
All the message headers are available to your script now, like so:
$fields{'Subject:'} is the information in Subject:
$fields{'To:'} is the information in the To: line.
$fields{'From:'} is who sent the message.
Any header that you see in the message can be called by printing it
exactly as it appears in a message - "Subject:", "Recieved:",
"Return-Path:" - whatever.
So, you could continue the script like this:
if ($fields{'Subject:'} =~ /PERL/)
{
open (OUT, ">>perlstuff.txt");
print OUT $body;
print OUT "\n\n";
close OUT;
}
else
{
open (PASSTHRU, ">>/var/spool/mail/username");
foreach $header (@headers)
{
print PASSTHRU "$header";
}
print PASSTHRU "\n$body \n";
close (PASSTHRU);
}
Now, if you get a message with "PERL" in the subject it will append
the body only to a file called perlstuff.txt, and otherwise it will
write the message to your mailbox so your pop3 client can retrieve it
as usual.
this is the basis for the ever-famous "Twit filter", too:
if ($fields{'From:'} eq /twit\@annoying\.com/i)
{
open (TRASH, ">/dev/null");
print "$body";
}
(now, you don't actually have to write it to /dev/null, but it just
feels better to know you sent the twit's message to the black hole)
This is so much simpler than trying to struggle with a module. It may
not be as elegant, but whatever works, works, right?
------------------------------
Date: Sat, 20 Jun 1998 15:49:06 -0700
From: fistful <fistful@pacbell.net>
Subject: Qustion for contract Perl scripters
Message-Id: <358C3C62.C71530D8@pacbell.net>
I have a question for contract perl scripters...
How many hours does it take for you to usually develop a script
to create:
1) a login/password page (for 100 different users)
2) an email with information included from a form with
the job # in the subject line
3) a script that takes information from a form and posts
it in a schedule table online
I'm trying to get an idea of how much money it would take to get these
things done. Any
advice would be greatly appreciated.
fistful
------------------------------
Date: 20 Jun 1998 23:32:18 GMT
From: c.c.eiftj@54.usenet.us.com (Rahul Dhesi)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6mhgq2$ju$1@samba.rahul.net>
In <vtvhpw5nhp.fsf@cliwe.ping.de> fdc@cliwe.ping.de (Frank D. Cringle) writes:
>c.c.eiftj@54.usenet.us.com (Rahul Dhesi) writes:
>> I believe some of the confusion arises because the word 'list' is used
>> both for lists as rvalues and as lvalues. If we had a new word such as
>> 'varlist' for a list when used on the LHS, we would have a cleaner set
>> of defintions.
>There is no requirement for the elements to be all lvalues or all
>rvalues. Is ($a, 1, $b, 2) a list or a varlist?
When a list is on the LHS of an assignment, every element of it must be
a variable. This is why 'varlist' is a better term than just 'list' in
this context.
--
Rahul Dhesi <dhesi@spams.r.us.com>
------------------------------
Date: Sat, 20 Jun 1998 23:26:33 GMT
From: mark-lists@webstylists.com (Mark Thompson)
Subject: Re: Sending file with Perl Script
Message-Id: <358c4464.13366705@news.alt.net>
On Sat, 20 Jun 1998 10:24:20 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>In article <358ce40e.5596560@news.alt.net>, Mark Thompson <mark-
>lists@webstylists.com> says...
>...
>> How do I control the filename that is used in the Save As dialog?
>> The file is a BinHex (Macintosh compressed) format file and having a filename
>> of formprocessor.pl doesn't really help the person know what to do with the
>> file they've just downloaded. I don't really want to have 100 different cgi
>> scripts called file1.hqx, file2.hqx . . . file100.hqx though I do know that I
>> could do it that way if needed.
>
>Getting further off-topic; consult with CGI folks. My thoughts: You
>can't 'control the filename' in any case -- all you can do is suggest.
>One way of suggesting is by resending your script with a unique PATH_INFO
>field:
>
>print "Location: http://.../$ENV{SCRIPT_NAME}/pathname\n\n";
>
>Consult with CGI folks.
Sorry, I tried posting to the cgi newsgroup but I ended up getting this self
moderation form that I returned but my message still never got forwarded to
the newsgroup. Plus, I find that when I look for answers before posting that
find that Perl is a better cgi group than the cgi group :)
------------------------------
Date: 20 Jun 1998 17:57:59 -0400
From: Dean Pentcheff <dean@mail.biol.sc.edu>
Subject: Re: Sort problems
Message-Id: <m3btrnwxaw.fsf@mail.biol.sc.edu>
Sifu Hall <webmaster@dragonslist.com> writes:
...
> My problem is this: I have read the FAQ and a book 'Teach Yourself
> Perl in 21 Days', but so far I can solve this problem. I am trying to
> sort a multiple dimensioned array on one specific element. For example,
> I have an array of @Schools and I would like to sort based on the third
> element, or $Schools[$i][3]. I have tried many variations to the code
> that was recommended to me and none seem to work correctly. I have
> modified the code to the following.
>
> sub arraysort {
> my(@MyArray) = @_;
> $NumItems = @MyArray;
> for ($i = 0; $i < $NumItems-1; $i +=1) {
> @sorted = sort {$Test[$i][3] cmp $Test[$i+1][3]}@MyArray;
> }
> return @sorted;
> }
...
Whoa! Hold it. You'll want to reread, in detail, the documentation
on the "sort" function. Sort, using a comparison function, returns
a copy of the original list in sorted order (the order determined by
the comparison function).
The comparison function (given in the "{}" after the "sort" keyword)
has the relatively simple job of just comparing two (any two) elements
of the list and returning their ordering status (<, >, or = 0,
depending on the comparison). Sort will call the comparison function
as many times as needed to figure out the sorted order, substituting
items from the real list for the magical variable names $a and $b.
Now, keep in mind that @schools is a list of references to other lists
(each of which has at least four elements). Um... do note that list
indices do (in general) start with 0 in Perl, so $list[3] returns the
fourth element in the list, not the third.
Anyway... In your comparison, $a and $b will be set (by sort) to the
elements of the main list. Since each of those is a reference to
another list (and it's the third element in _that_ list that you
need to pick out), you'll need to dereference the references.
Something like:
{$$a[2] cmp $$b[2] } # These two lines are alternative
{$a->[2] cmp $b->[2]} # syntax to do the same thing.
So, you could do the whole sort like this:
@sorted = sort {$$a[2] cmp $$b[2]} @MyArray;
The sort function itself does the crufty work of all the comparisons.
Since you can put anything into sort's comparison function (as long as
the last statement returns the result of the comparison!), it can be
fun to trace what sort ends up doing. For example:
#!/usr/local/bin/perl -w
use strict;
my(@arr) = (['fifth ', 5, 'fffff'],
['first ', 1, 'bbbbb'],
['third ', 3, 'ddddd'],
['second', 2, 'ccccc'],
['zeroth', 0, 'aaaaa'],
['fourth', 4, 'eeeee'],
);
print "Before: ", join(" ", map {$$_[2]} @arr), "\n";
my(@arr) = sort {print "$$a[2] vs. $$b[2]\n"; $$a[2] cmp $$b[2]} @arr;
print "After: ", join(" ", map {$$_[2]} @arr), "\n";
Hope that helps clarify things.
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)
------------------------------
Date: Sat, 20 Jun 1998 22:23:08 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Subtracting Number of seconds from a date
Message-Id: <358c35e1.45089722@news2.cais.com>
Tom Phoenix <rootbeer@teleport.com> Said this:
>On Fri, 19 Jun 1998, Matthew O. Persico wrote:
>
>> Subject: Re: Subtracting Number of seconds from a date
>>
>> How 'bout posting the solution?
>
>It's easy to work with dates in a variety of ways if you use the methods
>documented in the FAQ and the various date modules. There's no real need
>to post anything that's not better than those methods. Cheers!
>
Selena Sol's Date.pl works pretty well. It converts a "normal" date to
julian date, so you can then subtract from there. Since it's a julian
date, you won't have problems subtracting 5 days from June 3rd, and
getting June -2 or something, if you know what I mean.
------------------------------
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 2923
**************************************