sed /5/d with as little blabbage

Discussion in 'Perl Misc' started by Dan Jacobson, Jul 27, 2004.

  1. Dan Jacobson

    Dan Jacobson Guest

    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.
    Dan Jacobson, Jul 27, 2004
    #1
    1. Advertising

  2. Dan Jacobson

    Anno Siegel Guest

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


    Challenge? Next.

    [snip]

    Anno
    Anno Siegel, Jul 27, 2004
    #2
    1. Advertising

  3. Dan Jacobson

    Lukas Mai Guest

    Abigail schrob:
    > Dan Jacobson () wrote on MMMCMLXXXIII September
    > MCMXCIII in <URL:news:>:
    > .. 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,
    Lukas Mai, Jul 28, 2004
    #3
  4. Dan Jacobson

    Uri Guttman Guest

    >>>>> "LM" == Lukas Mai <> writes:

    LM> Abigail schrob:
    >> Dan Jacobson () wrote on MMMCMLXXXIII September
    >> MCMXCIII in <URL:news:>:
    >> .. 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.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Jul 28, 2004
    #4
  5. On 27 Jul 2004 21:10:40 GMT, Abigail <> wrote:

    >Dan Jacobson () wrote on MMMCMLXXXIII September
    >MCMXCIII in <URL:news:>:
    >.. 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, Jul 28, 2004
    #5
  6. On Wed, 28 Jul 2004 08:24:27 GMT, Uri Guttman <>
    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"
    Michele Dondi, Jul 28, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John K. Humkey

    sed regexp mystery

    John K. Humkey, Jul 8, 2003, in forum: Perl
    Replies:
    0
    Views:
    2,033
    John K. Humkey
    Jul 8, 2003
  2. NNTP

    sed awk or perl for this?

    NNTP, Sep 11, 2003, in forum: Perl
    Replies:
    13
    Views:
    3,461
    Alan Connor
    Sep 30, 2003
  3. gorda
    Replies:
    2
    Views:
    536
    Andrew Shitov
    Oct 21, 2003
  4. ThaDoctor
    Replies:
    3
    Views:
    371
    Alan Woodland
    Sep 28, 2007
  5. Daniel
    Replies:
    1
    Views:
    200
    Bart van Ingen Schenau
    Jul 9, 2013
Loading...

Share This Page