replace words

Discussion in 'Perl Misc' started by fred, Sep 8, 2009.

  1. fred

    fred Guest

    Thanks sln from @netherlands.com/

    xxxx&(ght)(hgf)&&(yyt)
    xx9x&(gg)(ff)&&(yyt)
    oixxx&(hfd)(jj)&&(yyt)
    xxxx&(jj)(kk)&&(yyt)
    xjhxxx&(jj)(j)&&(yyt)
    xjhxxx&(jj)(j)&&(yyt)
    xjhxxx&(jj)(j)&&(yyt)

    This command is working. I can change && for foo1 and foo2.
    perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&")eg' text.txt

    Please explain to me why the command is not working for foo3.
    perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&" : "&foo3&" )eg'
    text.txt
    Thanks
    fred, Sep 8, 2009
    #1
    1. Advertising

  2. fred

    Nathan Keel Guest

    fred wrote:

    > Thanks sln from @netherlands.com/
    >
    > xxxx&(ght)(hgf)&&(yyt)
    > xx9x&(gg)(ff)&&(yyt)
    > oixxx&(hfd)(jj)&&(yyt)
    > xxxx&(jj)(kk)&&(yyt)
    > xjhxxx&(jj)(j)&&(yyt)
    > xjhxxx&(jj)(j)&&(yyt)
    > xjhxxx&(jj)(j)&&(yyt)
    >
    > This command is working. I can change && for foo1 and foo2.
    > perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&")eg' text.txt
    >
    > Please explain to me why the command is not working for foo3.
    > perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&" : "&foo3&" )eg'
    > text.txt
    > Thanks


    The "condition ? value1 : value2" is an if/else condition. If the
    condition is true, it'll place value1 "or else" value2 if it's not met.
    If you want it to run another test before knowing if foo2 or foo3 is
    going to be placed, you need to add another conditional. Of course,
    it's not clear what you want to do in your example above. What do you
    want it to accomplish?
    Nathan Keel, Sep 8, 2009
    #2
    1. Advertising

  3. fred

    Uri Guttman Guest

    >>>>> "NK" == Nathan Keel <> writes:

    NK> fred wrote:

    >> This command is working. I can change && for foo1 and foo2.
    >> perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&")eg' text.txt
    >>
    >> Please explain to me why the command is not working for foo3.
    >> perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&" : "&foo3&" )eg'
    >> text.txt
    >> Thanks


    NK> The "condition ? value1 : value2" is an if/else condition. If the
    NK> condition is true, it'll place value1 "or else" value2 if it's not met.

    another great unclear answer. wtf does 'place' mean in that sentence?
    where does it 'place' something?
    how about showing him how to do a nested ?: or some other way of solving
    his problem?

    and try to learn some english grammar and writing skills before you
    attempt to help others in programming.

    uri

    --
    Uri Guttman ------ -------- http://www.sysarch.com --
    ----- Perl Code Review , Architecture, Development, Training, Support ------
    --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
    Uri Guttman, Sep 8, 2009
    #3
  4. fred

    Nathan Keel Guest

    Uri Guttman wrote:

    >>>>>> "NK" == Nathan Keel <> writes:

    >
    > NK> fred wrote:
    >
    > >> This command is working. I can change && for foo1 and foo2.
    > >> perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&")eg' text.txt
    > >>
    > >> Please explain to me why the command is not working for foo3.
    > >> perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&" : "&foo3&" )eg'
    > >> text.txt
    > >> Thanks

    >
    > NK> The "condition ? value1 : value2" is an if/else condition. If
    > the NK> condition is true, it'll place value1 "or else" value2 if
    > it's not met.
    >
    > another great unclear answer. wtf does 'place' mean in that sentence?


    **** you, you know what it means, you arrogant moron.

    > where does it 'place' something?


    What it's replacing with.

    > how about showing him how to do a nested ?: or some other way of
    > solving his problem?


    Firstly, it's because it's a poor design to work off of, and more
    importantly, it isn't clear what the OP wants it to do.

    Are you going to spend all day attacking me for no good reason (all
    because I don't put up with your shit) and ironically use that sort of
    attack nonsense to make your "point" about how my response could have
    been "more helpful", all the while you not helping at all and just
    ranting on about how much you don't like me, and then go on to
    "explain" how immature I am for calling you a prick for doing it?

    > and try to learn some english grammar and writing skills before you
    > attempt to help others in programming.


    Damn you're stupid. I have very good grammer and writing skills. You
    can't even use upper case for proper nouns, such as the word "English".
    It's fine if you don't like me for not tolerating your attempts to
    bully people on this usenet group, but you're just pathetic if you
    think you can be rude, immature, uncivil and use poor grammer, and then
    in doing so think you're making a valid point about why I suck. You
    are welcome to blame all of your emotional problems on me if you want
    to, but that's just sad. Boy, you really lose it when you can't push
    people around online. What a sad, sad little cowardly clown you are.

    > uri

    nal cake.
    Nathan Keel, Sep 8, 2009
    #4
  5. fred

    Uri Guttman Guest

    >>>>> "NK" == Nathan Keel <> writes:

    NK> Uri Guttman wrote:
    >>>>>>> "NK" == Nathan Keel <> writes:

    >>

    NK> fred wrote:
    >>
    >> >> This command is working. I can change && for foo1 and foo2.
    >> >> perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&")eg' text.txt
    >> >>
    >> >> Please explain to me why the command is not working for foo3.
    >> >> perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&" : "&foo3&" )eg'
    >> >> text.txt
    >> >> Thanks

    >>

    NK> The "condition ? value1 : value2" is an if/else condition. If
    >> the NK> condition is true, it'll place value1 "or else" value2 if
    >> it's not met.
    >>
    >> another great unclear answer. wtf does 'place' mean in that sentence?


    NK> **** you, you know what it means, you arrogant moron.

    but did the OP know? you were pathetically attempting to help him and
    you said nothing useful. 'place' isn't even properly used in your
    gibberish as it had no destination.

    >> where does it 'place' something?


    NK> What it's replacing with.

    there is nothing to replace there. it is an expression with a
    value. just more gibberish from you.

    >> how about showing him how to do a nested ?: or some other way of
    >> solving his problem?


    NK> Firstly, it's because it's a poor design to work off of, and more
    NK> importantly, it isn't clear what the OP wants it to do.

    it was fairly clear. he wanted a nested conditional or even something
    similar to the lisp cond function. it helps to know how to code in other
    langs to understand perl. try learning some one decade.

    NK> Are you going to spend all day attacking me for no good reason (all
    NK> because I don't put up with your shit) and ironically use that sort of
    NK> attack nonsense to make your "point" about how my response could have
    NK> been "more helpful", all the while you not helping at all and just
    NK> ranting on about how much you don't like me, and then go on to
    NK> "explain" how immature I am for calling you a prick for doing it?

    no, i try to correct poor answers. you seem to the major source of them
    recently. you will note i have done this for years and you are nothing
    compared to some others who claimed to 'help'.

    >> and try to learn some english grammar and writing skills before you
    >> attempt to help others in programming.


    NK> Damn you're stupid. I have very good grammer and writing skills. You

    spelled grammar. like i did just above you. hard to have good grammar if
    you can't even spell it correctly.

    >> uri

    NK> nal cake.

    you are so original. did you waste all of you dozen neurons working on
    that? are you so proud of it that you will use it forever? think i
    haven't seen nor heard stupid variants of my name before and it will
    actually hurt me? you are silly and worse if you think so. you can call
    me names, i will call you a dumb coder. one is a repeated childish
    retort, the other is a fact. facts win.

    uri

    --
    Uri Guttman ------ -------- http://www.sysarch.com --
    ----- Perl Code Review , Architecture, Development, Training, Support ------
    --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
    Uri Guttman, Sep 8, 2009
    #5
  6. fred

    Guest

    On Mon, 7 Sep 2009 16:51:55 -0700 (PDT), fred <> wrote:

    >Thanks sln from @netherlands.com/
    >
    >xxxx&(ght)(hgf)&&(yyt)
    >xx9x&(gg)(ff)&&(yyt)
    >oixxx&(hfd)(jj)&&(yyt)
    >xxxx&(jj)(kk)&&(yyt)
    >xjhxxx&(jj)(j)&&(yyt)
    >xjhxxx&(jj)(j)&&(yyt)
    >xjhxxx&(jj)(j)&&(yyt)
    >
    >This command is working. I can change && for foo1 and foo2.
    >perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&")eg' text.txt
    >
    >Please explain to me why the command is not working for foo3.
    >perl -0 -pe 's(&&)(++$n < 2 ? "&foo1&" : "&foo2&" : "&foo3&" )eg'
    >text.txt
    >Thanks


    Looks like your trying to do this, but not sure.

    perl -0 -pe 's(&&)(++$n; "&foo$n&")eg'

    xxxx&(ght)(hgf)&foo1&(yyt)
    xx9x&(gg)(ff)&foo2&(yyt)
    oixxx&(hfd)(jj)&foo3&(yyt)
    xxxx&(jj)(kk)&foo4&(yyt)
    xjhxxx&(jj)(j)&foo5&(yyt)
    xjhxxx&(jj)(j)&foo6&(yyt)
    xjhxxx&(jj)(j)&foo7&(yyt)

    -sln
    , Sep 8, 2009
    #6
  7. fred

    Nathan Keel Guest

    Uri Guttman wrote:

    > but did the OP know? you were pathetically attempting to help him and
    > you said nothing useful.


    Get a life, weirdo. Does it make you feel like a big man to try and
    harass people on usenet? Move on and grow up, troll boy.
    Nathan Keel, Sep 9, 2009
    #7
    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. Peter Strøiman
    Replies:
    1
    Views:
    2,072
    Peter Strøiman
    Aug 23, 2005
  2. Richard Heathfield
    Replies:
    7
    Views:
    350
    Barry Schwarz
    Oct 5, 2003
  3. utab

    Words Words

    utab, Feb 16, 2006, in forum: C++
    Replies:
    6
    Views:
    415
    Daniel T.
    Feb 16, 2006
  4. BerlinBrown
    Replies:
    6
    Views:
    4,438
  5. Lasse Edsvik

    replace words with bold words

    Lasse Edsvik, Oct 5, 2003, in forum: ASP General
    Replies:
    9
    Views:
    230
Loading...

Share This Page