home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3373
< prev
next >
Wrap
Internet Message Format
|
1991-05-20
|
1KB
From: rearl@watnxt3.ucr.edu (Robert Earl)
Newsgroups: comp.lang.perl,alt.sources
Subject: Re: perl version of from(1)
Message-ID: <REARL.91May20044441@watnxt2.ucr.edu>
Date: 20 May 91 11:44:41 GMT
In article <azioL/5ej/g.c@idunno.Princeton.EDU> subbarao@phoenix.Princeton.EDU (Kartik Subbarao) writes:
| Anyone know of a cooler way to do this?
It's Perl, there's ALWAYS a cooler way. :-)
| @subj = split(/[: ]/,$_);
| print ' "'.$subj[2].'"'."\n";
This was sort of confusing, did you really want it to print just the
first word of a subject? Mine won't do that, but it's easy enough to
change.
#! /usr/bin/perl
open(mail, $ENV{'MAIL'}) || exit;
while (<mail>) {
# skip this block unless it's "From ", else print it
/^From / || next; chop; print;
while (<mail>) {
chop;
# for the other way, substitute this line:
# ((length) ? s/^Subject: *([^: ]+)/print qq| "$1"\n|/e : print "\n")
((length) ? s/^Subject: */print qq| "$'"\n|/e : print "\n")
&& last;
}
}
print "\n";
print "Just another Perl hacker, ";
--
______________________________________________________________________
\
robert earl / "Love is a many splintered thing"
rearl@watnxt3.ucr.edu \ --Sisters of Mercy
rearl@gnu.ai.mit.edu /