Xref: utzoo comp.lang.perl:5378 alt.sources:3782 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!ucsd!ucrmath!rearl From: rearl@watnxt3.ucr.edu (Robert Earl) Newsgroups: comp.lang.perl,alt.sources Subject: Re: perl version of from(1) Message-ID: Date: 20 May 91 11:44:41 GMT References: Sender: news@ucrmath.ucr.edu Followup-To: comp.lang.perl Organization: (EVIL!) Lines: 40 In-reply-to: subbarao@phoenix.Princeton.EDU's message of 19 May 91 23:54:24 GMT In article 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 () { # skip this block unless it's "From ", else print it /^From / || next; chop; print; while () { 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 /