Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > sed /5/d with as little blabbage

Reply
Thread Tools

sed /5/d with as little blabbage

 
 
Dan Jacobson
Guest
Posts: n/a
 
      07-27-2004
Gentlemen, the challenge, to do as sed with as little blabbage,
$ seq 9|sed /5/d
$ seq 9|perl -ne 'next if /5/; print'
$ seq 9|perl -pe 'goto LINE if /5/'
Can I make it even shorter?

Perhaps this knows,
$ s2p '/5/d'|wc
123 459 2709
Never mind.
 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      07-27-2004
Dan Jacobson <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> Gentlemen, the challenge, to do as sed with as little blabbage,


Challenge? Next.

[snip]

Anno
 
Reply With Quote
 
 
 
 
Lukas Mai
Guest
Posts: n/a
 
      07-28-2004
Abigail schrob:
> Dan Jacobson ((E-Mail Removed)) wrote on MMMCMLXXXIII September
> MCMXCIII in <URL:news:(E-Mail Removed)>:
> .. Gentlemen, the challenge, to do as sed with as little blabbage,
> .. $ seq 9|sed /5/d
> .. $ seq 9|perl -ne 'next if /5/; print'
> .. $ seq 9|perl -pe 'goto LINE if /5/'
> .. Can I make it even shorter?


> $ seq 9|perl -pe'$_=""if/5/'


TIMTOWTDI:
$ seq 9|perl -ne'/5/||print'
$ seq 9|perl -pe's/5\n//'

Lukas
--
use warnings; use strict;
sub hacker'Perl { "Perl @_,"} sub another'Just
{print"Just @_ "}
Just another Perl hacker,
 
Reply With Quote
 
Uri Guttman
Guest
Posts: n/a
 
      07-28-2004
>>>>> "LM" == Lukas Mai <(E-Mail Removed)> writes:

LM> Abigail schrob:
>> Dan Jacobson ((E-Mail Removed)) wrote on MMMCMLXXXIII September
>> MCMXCIII in <URL:news:(E-Mail Removed)>:
>> .. Gentlemen, the challenge, to do as sed with as little blabbage,
>> .. $ seq 9|sed /5/d
>> .. $ seq 9|perl -ne 'next if /5/; print'
>> .. $ seq 9|perl -pe 'goto LINE if /5/'
>> .. Can I make it even shorter?


>> $ seq 9|perl -pe'$_=""if/5/'


LM> TIMTOWTDI:
LM> $ seq 9|perl -ne'/5/||print'
LM> $ seq 9|perl -pe's/5\n//'

that last one isn't the same thing. it only deletes the line if it is
just has (really just ends with) "5\n". the rest delete the line if it
has '5' in it.

uri

--
Uri Guttman ------ http://www.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
 
Reply With Quote
 
Michele Dondi
Guest
Posts: n/a
 
      07-28-2004
On 27 Jul 2004 21:10:40 GMT, Abigail <(E-Mail Removed)> wrote:

>Dan Jacobson ((E-Mail Removed)) wrote on MMMCMLXXXIII September
>MCMXCIII in <URL:news:(E-Mail Removed)>:
>.. Gentlemen, the challenge, to do as sed with as little blabbage,
>.. $ seq 9|sed /5/d
>.. $ seq 9|perl -ne 'next if /5/; print'
>.. $ seq 9|perl -pe 'goto LINE if /5/'
>.. Can I make it even shorter?
>
> $ seq 9|perl -pe'$_=""if/5/'


seq 9|perl -pe'$_ x=!/5/'
seq 9|perl -pe's/5.//s'


Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
 
Reply With Quote
 
Michele Dondi
Guest
Posts: n/a
 
      07-28-2004
On Wed, 28 Jul 2004 08:24:27 GMT, Uri Guttman <(E-Mail Removed)>
wrote:

> LM> $ seq 9|perl -ne'/5/||print'
> LM> $ seq 9|perl -pe's/5\n//'
>
>that last one isn't the same thing. it only deletes the line if it is
>just has (really just ends with) "5\n". the rest delete the line if it
>has '5' in it.


But since we're dealing with seq 9 here, both scripts produce the same
output so that they're most definitely equivalent per the OP's
request. And as far as I can say they would be similarly considered
completely equivalent by most golfing rules...


Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1 little 2 little 3 little Kennedys dale Digital Photography 0 03-23-2008 01:03 PM
add blank lines after word MAC (sed/awk or perl??) NNTP Perl 2 04-07-2004 06:04 AM
using perl on the command line, like sed or awk gorda Perl 2 10-21-2003 06:38 AM
sed awk or perl for this? NNTP Perl 13 09-30-2003 06:49 AM
sed regexp mystery John K. Humkey Perl 0 07-08-2003 03:55 AM



Advertisments