$str = 'hello'; for $c (split(//,$str)) { print "c=$c\n"; }However, usually in perl its better to use pattern matching to find something in a string.
Programming Tips - How do I split a string into characters so I can look at each one?
Date: 2011jul7
Language: perl
Q. How do I split a string into characters so I can look at each one?
A. Use split() with // as the pattern. For example: