C
clearguy02
Hi experts,
In my script, I need to check if a total number of characters in a
line is more than 10 or not and it it is >10, I should the cut the
original line to only 10 characters.
Example:
=============
$orig_line = "Perl is a good language";
$total_char = length ($orig_line)";
$second_line;
if ($total_char > 10)
{
print "The original's size is $total_char, but it should be
$second_line";
}
One way I can think is to get the difference between the $total_char
and the limit value (10) and after the finding the difference number,
I can truncate those many characters from the original line and store
that modified line in $second_line variable.
Does some one suggest me a shorter way of doing it?
Thanks,
J
In my script, I need to check if a total number of characters in a
line is more than 10 or not and it it is >10, I should the cut the
original line to only 10 characters.
Example:
=============
$orig_line = "Perl is a good language";
$total_char = length ($orig_line)";
$second_line;
if ($total_char > 10)
{
print "The original's size is $total_char, but it should be
$second_line";
}
One way I can think is to get the difference between the $total_char
and the limit value (10) and after the finding the difference number,
I can truncate those many characters from the original line and store
that modified line in $second_line variable.
Does some one suggest me a shorter way of doing it?
Thanks,
J