Link to home
Start Free TrialLog in
Avatar of gservice
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";
ASKER CERTIFIED SOLUTION
Avatar of mattrope
mattrope

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mattrope
mattrope

(By the way, the offset parameter to substr starts at 0 for the first character)
Avatar of ozo
#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"; ?