Vladi Belperchinov-Shabanski wrote:
#!/usr/bin/perl -p
$_='' if !/\S/ $e; # i.e. don't print if empty and last one was empty
$e = !/\S/; # remember if last one is empty...
#eof
Reading in a paragraph at a time rather than a line at a time helps
here. Perl's idea of a
* 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
On Mon, Sep 30, 2002 at 08:06:55PM +0200, Aristoteles Pagaltzis wrote:
perl -pe'!/\S/?($e++and$_=):($e=0)' filename
perl -pe'/\S/?($e=0):($e++and$_=)' filename
:)
Joy,
`/anick
--
Comedy is an escape, not from truth but from despair;
a narrow escape into faith.-- Christopher Fry
Uri Guttman wrote:
Y == Yanick [EMAIL PROTECTED] writes:
no one seems to have seen my earlier post on this so here it is again
and it is much shorter.
Y perl -pe'/\S/?($e=0):($e++and$_=)' filename
perl -0777pe's/^\s*\n/\n/m' file
This didn't work as is. It
On Mon, Sep 30, 2002 at 02:51:54PM -0400, Uri Guttman wrote:
Y == Yanick [EMAIL PROTECTED] writes:
no one seems to have seen my earlier post on this so here it is again
and it is much shorter.
Y perl -pe'/\S/?($e=0):($e++and$_=)' filename
perl -0777pe's/^\s*\n/\n/m'
PBE == Peter B Ensch [EMAIL PROTECTED] writes:
PBE Uri Guttman wrote:
Y == Yanick [EMAIL PROTECTED] writes:
no one seems to have seen my earlier post on this so here it is again
and it is much shorter.
Y perl -pe'/\S/?($e=0):($e++and$_=)' filename
perl
hi,
this is mine (a bit more obvious) solution:
#!/usr/bin/perl -p
$_='' if !/\S/ $e; # i.e. don't print if empty and last one was empty
$e = !/\S/; # remember if last one is empty...
#eof
:)
P! Vladi.
On Mon, 12 Aug 2002 13:28:19 -0400
Selector, Lev Y [EMAIL PROTECTED]
Folks,
I have a long file which has many empty lines
with nothing but may be spaces or tabs (/^\s*$/).
These lines tend to group together creating chunks
of empty vertical space on the printout.
I want to reduce the number of empty lines
in such chunks to 1 line.
What would be an elegant
On Mon, Aug 12, 2002 at 01:28:19PM -0400, Selector, Lev Y wrote:
Folks,
I have a long file which has many empty lines
with nothing but may be spaces or tabs (/^\s*$/).
These lines tend to group together creating chunks
of empty vertical space on the printout.
I want to reduce the
Wow!
This was fast.
And it works too!
Warmest Regards,
Lev Selector
-Original Message-
From: Ronald J Kimball [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 12, 2002 1:33 PM
To: Selector, Lev Y
Cc: [EMAIL PROTECTED]
Subject: Re: removing extra empty lines
On Mon, Aug 12, 2002
On Mon, Aug 12, 2002 at 01:32:45PM -0400, Ronald J Kimball wrote:
What would be an elegant way to do this?
perl -p0377i -e 's/^\s*$//gm'
what about files with character 255 in them? (aka \0377)?
I think this should read
perl -p0777i ...
On Mon, 12 Aug 2002, Bennett Todd wrote:
=Elegant is in the eye of the beholder.
=
=I'd tend to use a pipeline
=
= perl -lpe 's/\s+$//'|uniq
=
=but I'm sure others find other approaches more elegant. Mine is
=admittedly not perl-only, but |uniq is probably quicker to type
=than even a golf
12 matches
Mail list logo