if I have a string, say:
my $string = "A, B,C, D , E ";
How can I put this into an array in Perl without the leading and trailing spaces? So what I want is only a single letter in each array element. What I currently do is this:
my @groups = split /,\s*/, $string;
But this is obviously not enough, as the trailing spaces are still there. Any help appreciated. Thanks a lot !!
Then strip leading/trailing spaces before you split and match the leading/trailing spaces in the split expression.
Using a module like Text::CSV is probably better than trying to do your own CSV parsing, though.