How to read a string into an array of characters using split
Perl’s split function has a useful feature that will split a string into characters. This works by supplying an empty regex pattern (“//”) to the split function. This can be used to easily split a word into an array of letters, for example:
my $word = 'camel'; my @letters = split(//, $word);
Perl’s official documentation has more on the split function. You can read it online or by running the following command at the terminal:
perldoc -f split
This article was originally posted on PerlTricks.com.
Something wrong with this article? Help us out by opening an issue or pull request on GitHub