Hey guys, can help me out with this?
How do i limit output for xml to 50 character?
i tried *below* but doesnt work, it still print more than 50 characters.
Thanks in advance
printf "%-50s", "$testline\n";
Hey guys, can help me out with this?
How do i limit output for xml to 50 character?
i tried *below* but doesnt work, it still print more than 50 characters.
Thanks in advance
printf "%-50s", "$testline\n";
You could use a function like that below (UNTESTED CODE)
sub limit{
my ($string, $limit)=shift;
return length($string)>$limit ? substr($string, 0, $limit) : $string;
}
...
printf limit($testline, 50);
print substr($testline, 0, 50), "\n"
you can use substr function
printf "%s\n", substr $testline,0,50;
substr work great.. thanks alot guys