Counting the # of characters in a multi-line string
- From: mike.wilson8@xxxxxxxxxxx
- Date: 26 Sep 2006 07:55:31 -0700
I've been taking little baby steps on understanding how to read
multi-line strings as some of you have been seeing in the past week or
so. I've been posting the [DOT multiline strings].
My next goal is to count the total nunber of characters in a string and
the number of chomps that I did.
Code:
while(<IN>)
{
chomp ();
$DOTct = length ($_);
print "$DOTct\n";
last if /.*\]/;
}
What I'm producing is a character count per $_.
Output ex:
4
4
4
What I'm trying to do is total the count and get 12. Do I need to set
a line counter to 0 and increment from $_?
Also, is there a way to count the number of chomps that was done during
the read?
Thank you,
Mike
.
- Follow-Ups:
- Re: Counting the # of characters in a multi-line string
- From: usenet
- Re: Counting the # of characters in a multi-line string
- From: DJ Stunks
- Re: Counting the # of characters in a multi-line string
- From: DJ Stunks
- Re: Counting the # of characters in a multi-line string
- Prev by Date: Re: perl scalar
- Next by Date: Re: Counting the # of characters in a multi-line string
- Previous by thread: Need help editing a string
- Next by thread: Re: Counting the # of characters in a multi-line string
- Index(es):
Relevant Pages
|
|