Convert String Array


Converting a string into an array



To convert a string to an array, use split.



Here we have a string, comprising of fields separated by commas.

So we just split on the comma, but this could also be spaces, etc.

@rr=split ',', $str;
print $#rr."n"; # outputs 2



[tags], Perl Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *