Re: [AMBER] How to use perl to replace number to txt?

From: M. L. Dodson <mldodson.comcast.net>
Date: Thu, 31 Mar 2011 09:31:36 -0500

On Mar 31, 2011, at 5:19 AM, Hannes Loeffler wrote:

> Hi Catherine,
>
> I don't really think that this mailing list is the right place to
> discuss Perl basics. There are ample beginner tutorials out there.
> It might be a good idea to read through some of them.
>

I completely agree with Hannes, but I think you will find 1..100 works
better (two .). I haven't tried the rest of your syntax, and that is
not the way I would write it, so caveat emptor.

Bud Dodson

>
> On Thu, 31 Mar 2011 17:48:48 +0800
> Catein Catherine <askamber23.hotmail.com> wrote:
>
>>
>> Dear Sir or Madam,
>>
>> I was trying to use perl to do amber analysis. One of my task is to
>> replace the (number 1 to 100) to a txt (xxx).
>> I was using the following command line in perl.
>>
>> s/1...100/xxx/g
>
> This will replace a string starting with 1, followed with three
> arbitrary characters, followed by the string '100' with the string
> 'xxx' for every occurence of the input.
>
> You will need to learn at least the basics of regular expressions if
> you want to use the substitution mechanism.
>
>
>> However, the program seems to have problem reading [1...100], as it
>> only change 1 to xxx.
>> I tried to specifiy the 1...100 as follows
>>
>> s/1,2,3,4,5,6,7,8,9,10,11,..../xxx/g
>
> This replaces the string '1,2,3,4,5,6,7,8,9,10,11,' followed by four
> arbitrary characters.
>
>
>> However, this time, only 1 to 10 was changed to xxxx. The 10 was
>> changed to xxx0, 11, was changed to xxxxxx. It seems to me that perl
>> read 10 as 1 + 0, 11 as 1 + 0.
>
> You are obviously operating on strings and not numbers.
>
>
>> Could you mind to give me a hand how
>> to overcome this problem? Are there any easier way of doing this?
>
> Without knowing the input it is difficult to give a general answer.
> Regular expressions may not be the right answer. You may have to
> split the input manually and treat numbers as such.
>
>
> Cheers,
> Hannes.
>
> _______________________________________________
> AMBER mailing list
> AMBER.ambermd.org
> http://lists.ambermd.org/mailman/listinfo/amber

-- 
M. L. Dodson
Business email: activesitedynamics-at-gmail-dot-com
Personal email: mldodson-at-comcast-dot-net
Gmail: mlesterdodson-at-gmail-dot-com
Phone: eight_three_two-five_63-386_one
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Thu Mar 31 2011 - 08:00:03 PDT
Custom Search