replace words

F

fred

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
 
N

Nathan Keel

fred said:
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?
 
U

Uri Guttman

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
 
N

Nathan Keel

Uri said:
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.
nal cake.
 
U

Uri Guttman

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.

NK> What it's replacing with.

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

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'.

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.
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
 
S

sln

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
 
N

Nathan Keel

Uri said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top