For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > July 2004 > sed /5/d with as little blabbage









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author sed /5/d with as little blabbage
Dan Jacobson

2004-07-28, 9:01 pm

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.
Anno Siegel

2004-07-28, 9:01 pm

Dan Jacobson <jidanni@jidanni.org> wrote in comp.lang.perl.misc:
> Gentlemen, the challenge, to do as sed with as little blabbage,


Challenge? Next.

[snip]

Anno
Abigail

2004-07-28, 9:01 pm

Dan Jacobson (jidanni@jidanni.org) wrote on MMMCMLXXXIII September
MCMXCIII in <URL:news:87zn5mi7ug.fsf@jidanni.org>:
... 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/'


Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
Lukas Mai

2004-07-28, 9:01 pm

Abigail schrob:
> Dan Jacobson (jidanni@jidanni.org) wrote on MMMCMLXXXIII September
> MCMXCIII in <URL:news:87zn5mi7ug.fsf@jidanni.org>:
> .. 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,
Uri Guttman

2004-07-28, 9:01 pm

>>>>> "LM" == Lukas Mai <rwxr-xr-x@gmx.de> writes:

LM> Abigail schrob:[color=darkred]
[color=darkred]

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 ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Michele Dondi

2004-07-28, 9:01 pm

On 27 Jul 2004 21:10:40 GMT, Abigail <abigail@abigail.nl> wrote:

>Dan Jacobson (jidanni@jidanni.org) wrote on MMMCMLXXXIII September
>MCMXCIII in <URL:news:87zn5mi7ug.fsf@jidanni.org>:
>.. 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"
Michele Dondi

2004-07-28, 9:01 pm

On Wed, 28 Jul 2004 08:24:27 GMT, Uri Guttman <uri@stemsystems.com>
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"
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com