Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > replace words

Reply
Thread Tools

replace words

 
 
fred
Guest
Posts: n/a
 
      09-07-2009
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
 
Reply With Quote
 
 
 
 
Nathan Keel
Guest
Posts: n/a
 
      09-08-2009
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?
 
Reply With Quote
 
 
 
 
Uri Guttman
Guest
Posts: n/a
 
      09-08-2009
>>>>> "NK" == Nathan Keel <(E-Mail Removed)> 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.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
Reply With Quote
 
Nathan Keel
Guest
Posts: n/a
 
      09-08-2009
Uri Guttman wrote:

>>>>>> "NK" == Nathan Keel <(E-Mail Removed)> 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 ****) 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.

 
Reply With Quote
 
Uri Guttman
Guest
Posts: n/a
 
      09-08-2009
>>>>> "NK" == Nathan Keel <(E-Mail Removed)> writes:

NK> Uri Guttman wrote:
>>>>>>> "NK" == Nathan Keel <(E-Mail Removed)> 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 ****) 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 ------ (E-Mail Removed) -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
Reply With Quote
 
sln@netherlands.com
Guest
Posts: n/a
 
      09-08-2009
On Mon, 7 Sep 2009 16:51:55 -0700 (PDT), fred <(E-Mail Removed)> 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
 
Reply With Quote
 
Nathan Keel
Guest
Posts: n/a
 
      09-09-2009
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.
 
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
Replace stop words (remove words from a string) BerlinBrown Python 6 01-17-2008 02:37 PM
Words Words utab C++ 6 02-16-2006 07:00 PM
Non-noise words are incorrectly recognised as noise words. Peter Strĝiman ASP .Net 1 08-23-2005 01:26 PM
replace words with bold words Lasse Edsvik ASP General 9 10-07-2003 01:19 PM
Re: A little bit of help regarding my linked list program required. - "words.c" - "words.c" Richard Heathfield C Programming 7 10-05-2003 02:38 PM



Advertisments