Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    55

    Unanswered: last char of a string

    Hi again every1

    I just wanetd to know if there is some way of checking the last character of a string....tht is checking it without finding the length and goin thru the whole string..
    Is there a predefined function in perl tht returns the last char of a string without altering the string itself?
    fr example if i have

    $str="string."
    i want to returm just "." and
    $str should be still="string."

    please let me know and thnx in advance frne hlpe provided

    cheers
    -s
    You try and try again..but then give up, there's no sense in being a complete fool about it!!!

  2. #2
    Join Date
    Sep 2002
    Location
    Germany, near Aachen
    Posts
    120
    $last = substr($str, -1, 1)

  3. #3
    Join Date
    Jan 2003
    Posts
    55

    thnx

    thanx..that worked beautifully

    -s
    You try and try again..but then give up, there's no sense in being a complete fool about it!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •