in reply to Re: Count number of lines in a STRING
in thread Count number of lines in a STRING
better use scalar split, counting the delimiter is unnecessary complexity.
DB<1> $a="1\n2\n3";$b=$a."\n" DB<2> print scalar split /\n/ for $a,$b 33 DB<3> print scalar tr/\n// for $a,$b 23
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Count number of lines in a STRING
by JavaFan (Canon) on May 12, 2010 at 10:10 UTC | |
by LanX (Saint) on May 12, 2010 at 10:48 UTC |