On Sat, Feb 26, 2011 at 12:34 PM, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "PK" == Parag Kalra <paragka...@gmail.com> writes: > > PK> use strict; > PK> use warnings; > PK> while(<DATA>){ > PK> chomp; > > why are you chomping here when you add in the \n later? > Agreed and corrected in the example at the bottom. > PK> if ($_ =~ /NM_(\d+)/){ > PK> my $found = $1; > PK> $_ =~ s/$found/$found:12345/g; > > many issues there. why do you test the match before making the s///? you > can ALWAYS do an s/// as it will just fail if it doesn't match. > Rectified in the example at the bottom. > > why are you doing s/// against $_? by default it does that. > > PK> print "$_\n"; > PK> } else { > PK> print "$_\n"; > PK> } > > why are you printing the same thing in each clause? just print AFTER the > change is made? > Big mistake. I accept it. Modified in the example at the bottom. > > > why do you top post when you have been told to bottom post and edit the > quoted email? > Sorry. Hope this reply is better and so as the following code: use strict; use warnings; while(<DATA>){ $_ =~ s/NM_(\d+)/$1:12345/g; print; } __DATA__ chr1 ucsc exon 226488874 226488906 0.000000 - . gene_id "NM_173083"; transcript_id "NM_173083"; chr1 ucsc exon 226496810 226497198 0.000000 - . gene_id "NM_173083"; transcript_id "NM_173083"; chr1 ucsc exon 2005086 2005368 0.000000 + . gene_id "NM_001033581"; transcript_id "NM_001033581"; chr1 ucsc exon 2066701 2066786 0.000000 + . gene_id "NM_001033581"; transcript_id "NM_001033581"; > > uri > Thanks for the review ~Parag > > -- > Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com-- > ----- Perl Code Review , Architecture, Development, Training, Support > ------ > --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com--------- >