Re: Counting the # of characters in a multi-line string
- From: "DJ Stunks" <DJStunks@xxxxxxxxx>
- Date: 26 Sep 2006 08:32:35 -0700
mike.wilson8@xxxxxxxxxxx wrote:
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?
help us help you, Mike. that is, for best results, post a short, but
complete script which shows us what you have tried. complete means:
1) the shebang line
2) use strict;
3) use warnings;
4) supply any sample data either as a variable in the script or
in the special __DATA__ filehandle
these pieces of information will help you help yourself and help us
understand exactly what you're trying to do and what is causing
whatever issue it is you're seeing.
-jp
.
- References:
- Counting the # of characters in a multi-line string
- From: mike . wilson8
- Counting the # of characters in a multi-line string
- Prev by Date: Counting the # of characters in a multi-line string
- Next by Date: Re: backreference in regexp
- Previous by thread: Counting the # of characters in a multi-line string
- Next by thread: Re: Counting the # of characters in a multi-line string
- Index(es):
Relevant Pages
|
|