randomhero1270 has asked for the wisdom of the Perl Monks concerning the following question:
Hi! I am very new to perl. I love programming but I am just not very good at it. I am trying to use regex's to read a file which contains a bunch of these R00005: 00330: C01010 => C00011 R00005: 00791: C01010 => C00011 R00005: 01100: C01010 <=> C00011 R00006: 00770: C00022 => C00900 R00008: 00362: C06033 => C00022 R00008: 00660: C00022 => C06033 R00010: 00500: C01083 => C00031 R00013: 00630: C00048 => C01146 R00013: 01100: C00048 <=> C01146 what it needs to do is print the R_____ then whichever => follows it. for example it would need to find R00008 and print => I don't really understand how regex works so I started with this
and it just prints nononononononononononono etc... I thought that was right? any help is appreciated thank you!use strict; open(DNA, 'reaction_mapformula.lst'); while(my $protein = <DNA>) { if(my $protien =~ m/^R\d\d\d\d\d$/){ print "it"; }else{ print "no"; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex help
by ww (Archbishop) on Sep 18, 2012 at 21:51 UTC | |
Re: Regex help
by hbm (Hermit) on Sep 18, 2012 at 21:25 UTC | |
Re: Regex help
by Kenosis (Priest) on Sep 18, 2012 at 22:48 UTC | |
by randomhero1270 (Novice) on Sep 19, 2012 at 14:30 UTC | |
by Kenosis (Priest) on Sep 19, 2012 at 15:55 UTC | |
Re: Regex help
by nemesdani (Friar) on Sep 18, 2012 at 21:12 UTC |