|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello.
I have a PERL script that takes text data from a VARCHAR variable of a MySQL table, and prints it to an HTML table. I would like to be able to only print a certain number of characters (like the first 15, for example) of the string, to keep the table width the same size. How is this possible? Thanks! yoshi http://www.datera.com |
|
#2
|
||||
|
||||
|
Hi yoshi,
you can use substr() function for that.just cut 15 character from the string and display it. eg: $str="I Love My Jesus," $str=substr($str,0,15); #cut first 15 chartcters print $str; ------------------ SR - shiju.dreamcenter.net "I will love thee, O Lord,my strength" |
|
#3
|
|||
|
|||
|
In addition to Shiju's example,
eg: $str="I Love My Jesus,"; You can also determine the length of $str with this.. $length = length $str; # length gets value of 16. Anything (including white spaces) between the quotes counts. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Setting number of chars to print (from MySQL)? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|