note
nagalenoj
<b><i>TIMTOWTDI</i></b>
<p>Here's is the another way.<u>Treating the scalar as a file handle.</u></p>
<code>
use strict;
use warnings;
use IO::Scalar;
my $string = "one\ntwo\nthree\nfour\nfive\nsix";
my $scalar_fh = IO::Scalar->new( \$string ); # creating a scalar file handle.
my $count = 0;
$count++ while (<$scalar_fh> );
print $count;
</code>
<p>This is not efficient than using tr. But, you can process a string as file by this way.<p>
839575
839575