sugar has asked for the wisdom of the Perl Monks concerning the following question:
please let me know where i am going wrong !!! P.S: i have not included use strict and warnings;input file: ---------- >IDnumber1 length=350 AGCTG >IDnumber2 length=350 AGAACGT >IDnumber3 length=350 AGC expected output file: ---------------------- >IDnumber1 length=5 AGCTG >IDnumber2 length=7 AGAACGT >IDnumber3 length=3 AGC code: ----- #!/usr/bin/perl open FH,"inputfile"; while(<FH>){ $head=();$str=(); if($_=~m/^>/){ ($head,$x)=split(' ',$_); } else{ $str=$_; chomp($str); $len=length($str); } print "$head Length=$len\n"; print "$str\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: printing the length of string variables
by prasadbabu (Prior) on Jan 08, 2009 at 07:25 UTC | |
by sugar (Beadle) on Jan 08, 2009 at 07:42 UTC | |
|
Re: printing the length of string variables
by chromatic (Archbishop) on Jan 08, 2009 at 07:28 UTC | |
|
Re: printing the length of string variables
by ikegami (Patriarch) on Jan 08, 2009 at 07:27 UTC | |
|
Re: printing the length of string variables
by ikegami (Patriarch) on Jan 08, 2009 at 12:21 UTC | |
|
Re: printing the length of string variables
by sanku (Beadle) on Jan 08, 2009 at 11:38 UTC |