gservice
asked on
Finding the length of a string
How can I find the length of a string and access separately each position:
say: $string = "ABCD"
and I need to use $access[1] = "B";
say: $string = "ABCD"
and I need to use $access[1] = "B";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(By the way, the offset parameter to substr starts at 0 for the first character)
#if you want to deal with an array of characters, you can use
@access=split//,$string;
#but there are often better ways in perl to do things that you might do by accessing separately each position of a string in other languages.
#why do you need to use $access[1] = "B"; ?
@access=split//,$string;
#but there are often better ways in perl to do things that you might do by accessing separately each position of a string in other languages.
#why do you need to use $access[1] = "B"; ?