Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: printing the length of string variables

by prasadbabu (Prior)
on Jan 08, 2009 at 07:25 UTC ( #734830=note: print w/replies, xml ) Need Help??

in reply to printing the length of string variables

Hi sugar,

If I understood your requirement correctly, the below coding which is slightly modified form of yours will work. But you can do the same in more simple way.

use strict; use warnings; my ($head); while(<DATA>){ my ($x, $str, $len, $s); $s = $_; if($s=~m/^>/){ chomp($s); ($head)=(split(/ /,$s))[0]; } else{ chomp($s); $len=length($s); } print "$head length=$len\n$s\n" if($s !~m/^>/); } __DATA__ >IDnumber1 length=350 AGCTG >IDnumber2 length=350 AGAACGT >IDnumber3 length=350 AGC output: ------- >IDnumber1 length=5 AGCTG >IDnumber2 length=7 AGAACGT >IDnumber3 length=3 AGC


Replies are listed 'Best First'.
Re^2: printing the length of string variables
by sugar (Sexton) on Jan 08, 2009 at 07:42 UTC
    Oh yea, your right. I just realized it :) Thanks for the help.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://734830]
[marto]: think targeted ads
[marto]: "your house is so big, consider product XYZ", "You clean a lot, consider product ABC"
Discipulus your house is so small, accept dollars from nigeria
[marto]: Discipulus, or space saving products, that sort of thing

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (11)
As of 2017-07-26 12:05 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (390 votes). Check out past polls.