Using perl, is there any one command that gives me the number of lines inside a line?
perl
my $linenum= .... $str ....
It should work when a line is empty, one line and several lines.
Try using regex
You can count the number of newline characters \nper line (or \rfor a newline Mac)
\n
\r
my $linenum = $str =~ tr/\n//;