Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: printing the length of string variables

by prasadbabu (Prior)
on Jan 08, 2009 at 07:25 UTC ( [id://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

Prasad

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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://734830]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found