Date sent:              Thu, 9 Nov 2006 21:34:35 -0800 (PST)
From:                   ppp ppp <[EMAIL PROTECTED]>
Subject:                Help  regular expression 
To:                     beginners@perl.org

> Hi All ;
> 
> 
> I am new to this group.I am just started to learn perl.I want to
> program in perl or C that it input text file(.txt) and it should find
> every Uppercase letters(Capital letter) in the input file converts
> every capital letter say with one letter d and lower case
> letters(small letters) replaces with letter O.
> 
> for eg.(input file- eg1.txt)
> >protein1
> afagaDRTYUagagfaa
> >protein 2
> DFafagagRTUI
> 
> output file (eg2.txt)
> >protein1
> ooooodddddooooooo
> >protein2
> ddoooooodddd
> 
>   My code 
> 
>   while($string=<>) {
>   $string=~ tr/[A-Z,a-z]/[d,o]/ ;
>   print $string ;}

The stuff within tr/// is NOT a regexp! Therefore no [] is necessary. 
And in either case, no commas please! I think you want 

        $string=~ tr/a-z/o/;
        $string=~ tr/A-Z/d/;

or maybe 

        $string=~ tr/A-Za-
z/ddddddddddddddddddddddddddoooooooooooooooooooooooooo/;

but that's a bit dangerous, it's easy to make a mistake and transform 
some capital letter to "o".

HTH, 
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to