* Vladi Belperchinov-Shabanski <[EMAIL PROTECTED]> [2002-09-30 19:24]:
> > > $_='' if !/\S/ && $e;   # i.e. don't print if empty and last one was empty
> > > $e = !/\S/;             # remember if last one is empty...
> > 
> > Since you have already done $_='' in the first line, you
> > don't need a regex in the second to set $e. You can just say
> > 
> > $e = !$_;
> 
> line `0' will fail this test, though it is not empty line...

Doh, ack.

Assuming no warnings, I offer this:

undef $_ if !/\S/ && $e;
$e = not defined;


Or assuming warnings but no undefined values:

$_="" if !/\S/ && $e;
$e = not length;


Ohh, may I golf?

perl -pe'!/\S/?($e++and$_=""):($e=0)' filename

-- 
Regards,
Aristotle

Reply via email to