Re: Counting the # of characters in a multi-line string



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

.



Relevant Pages

  • ruby/tk and script encoding
    ... I have big problems with supporting the iso8859-2 characters in my ... The TixCombobox can be configured to callback a proc when the ... have inserted to the combobox earlier from my script (i.e., ... So, it seems, that on one machine, the strings from my script are ...
    (comp.lang.tcl)
  • Re: Counting the # of characters in a multi-line string
    ... I've been posting the [DOT multiline strings]. ... My next goal is to count the total nunber of characters in a string and ... is there a way to count the number of chomps that was done during ...
    (perl.beginners)
  • Counting the # of characters in a multi-line string
    ... I've been posting the [DOT multiline strings]. ... My next goal is to count the total nunber of characters in a string and ... is there a way to count the number of chomps that was done during ...
    (perl.beginners)
  • Re: Why R6RS is controversial
    ... the semantics of the language, ... behavior of grapheme-cluster characters under most linguistic ... as the strings grow longer. ... Normalization is hideously complicated, and may require many ...
    (comp.lang.scheme)
  • Re: Unicode LISP??
    ... I'm not experienced with Common Lisp library, ... terms of strings rather than characters. ... have their representation upgraded if they are updated in place. ...
    (comp.lang.lisp)