in reply to Length and Chomp ??
The reason you get 6 instead of 5 is because the value of $str is "snape\n". That newline is the sixth character.
I imagine that what you were doing with chomp was something like $str = chomp $str. This is incorrect. chomp will return the number of newlines removed from the end of the string, so you actually end up assigning "1" to $str, which indeed does have a length of 1.
|
|---|