perl version of from(1)

Robert Earl rearl at watnxt3.ucr.edu
Mon May 20 21:44:41 AEST 1991


In article <azioL/5ej/g.c at idunno.Princeton.EDU> subbarao at 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 at watnxt3.ucr.edu	\		--Sisters of Mercy
 rearl at gnu.ai.mit.edu	/



More information about the Alt.sources mailing list