Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!math.lsa.umich.edu!math.lsa.umich.edu!emv From: emv@math.lsa.umich.edu (Edward Vielmetti) Newsgroups: comp.lang.perl Subject: Re: Deleting (Only) First Blank Line in File Message-ID: Date: 1 Jul 90 21:56:29 GMT References: <1651@fallst.UUCP> <1990Jun30.214249.15211@iwarp.intel.com> Sender: usenet@math.lsa.umich.edu Distribution: comp Organization: University of Michigan Math Dept., Ann Arbor MI. Lines: 30 In-Reply-To: merlyn@iwarp.intel.com's message of 30 Jun 90 21:42:49 GMT In article <1990Jun30.214249.15211@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: | Solutions other than those using 'perl' are preferred. But, since you didn't say *necessary*, how about: perl -ne 'print unless /^$/ && $once++;' hm, nice. how about this problem: printing the first 10 lines after a signal line? I would think it could be done with the .. operator, namely perl -ne 'if (/===/) {$l = $. + 10 ;} ; if (/===/ .. $l) {print;} ' but this prints only the === line and the one following. a test with digits shows that it works as expected for this: perl -ne 'if (/===/) {$l = $. + 10 ;} ; if (/===/ .. 50) {print;} ' which lead me to experiment with the following which worked perl -ne 'if (/===/) {$l = $. + 10 ;} ; eval "if (/===/ .. $l) {print;}"; ' the eval appears to be neccesary in order to force the .. to be interpreted in a scalar context, but I guess I don't really understand the man page, & in retrospect a simple loop would have done the trick OK. --Ed Edward Vielmetti, U of Michigan math dept