Click here to get back home

Help: Reverse Letters

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Help: Reverse Letters Amy Lee 05-02-2008
Posted by Jürgen Exner on May 2, 2008, 11:15 am
Please log in for more thread options
>>>There's a problem while I'm processing sequences. My file content.
>>>ATGCCCTGACGTAAACGTAGGCTACG
>>>And I hope I can reverse the sequences to be this.
>>>GCATCGGATGCAAATGCAGTCCCGTA
>>
>> You asked a self answering question: The reverse() function does exactly
>> that.
>>
>>>I use "reverse" to do this, but it dose not work any more.
>>
>> ?????
>> Are you saying that coming back into the office after yesterday's Labour
>> Day the functionality of reverse() in Perl has changed?
> unless (/^>.*$/)
> {
> reverse $_;
> }

Had you used
        use warnings; use strict;
as it strongly recommended then perl itself would have told you:

        "Useless use of reverse in void context at [...] line [...]."

In other words: You reverse the content of $_ and then throw it away.

jue

Posted by RedGrittyBrick on May 2, 2008, 10:52 am
Please log in for more thread options
Amy Lee wrote:
> Hello,
>
> There's a problem while I'm processing sequences. My file content.
>
>> seq1
> ATGCCCTGACGTAAACGTAGGCTACG
>> seq2
> GCATGCCCTACGGGTACCCCAGTA
>
> And I hope I can reverse the sequences to be this.
>
>> seq1
> GCATCGGATGCAAATGCAGTCCCGTA
>> seq2
> ATGACCCCATGGGCATCCCGTACG
>
> I use "reverse" to do this, but it dose not work any more.
> So could you tell me how to solve this problem?
>

reverse needs a list

$ perl -e '$x="GCAT";$y=join"",reverse(split "",$x);print"$y\n"'
TACG

doubtless there are better ways to do this.

--
RGB

Posted by RedGrittyBrick on May 2, 2008, 10:55 am
Please log in for more thread options
RedGrittyBrick wrote:
> Amy Lee wrote:
>> Hello,
>>
>> There's a problem while I'm processing sequences. My file content.
>>
>>> seq1
>> ATGCCCTGACGTAAACGTAGGCTACG
>>> seq2
>> GCATGCCCTACGGGTACCCCAGTA
>>
>> And I hope I can reverse the sequences to be this.
>>
>>> seq1
>> GCATCGGATGCAAATGCAGTCCCGTA
>>> seq2
>> ATGACCCCATGGGCATCCCGTACG
>>
>> I use "reverse" to do this, but it dose not work any more.
>> So could you tell me how to solve this problem?
>>
>
> reverse needs a list
>
> $ perl -e '$x="GCAT";$y=join"",reverse(split "",$x);print"$y\n"'
> TACG
>

Oh no it doesn't! How embarassing.

perl -e '$x="GCAT";$y=reverse($x);print"$y\n"'
TACG

--
RGB

Similar ThreadsPosted
Matching words and letters December 8, 2004, 11:33 pm
Lower casing letters of words July 15, 2005, 8:35 am
How to manipulate the cases of letters in a string? October 4, 2007, 7:47 pm
Getting Perl to ignore Letters when calculating numbers. March 30, 2005, 9:54 pm
regular expression consecutive numbers or letters November 1, 2006, 11:10 am
Perl Regex Question: how to translate only the leading letters of a line July 10, 2004, 4:52 pm
reverse dns August 18, 2006, 2:40 pm
FAQ 4.24 How do I reverse a string? May 12, 2005, 11:03 pm
FAQ 4.24 How do I reverse a string? January 21, 2005, 6:03 pm
FAQ 4.24 How do I reverse a string? July 28, 2005, 4:03 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap