#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    108
    Rep Power
    15
    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. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    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"
  4. #3
  5. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    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.

IMN logo majestic logo threadwatch logo seochat tools logo