I want to split a string on keywords. The keywords match / [A-Z]+=/ (a space, the keyword in all caps, then an equal sign). While I want to split the string up into a nice, easy-to-use array, I need to keep the keyword with the array items. Or can I create an assoc array with the keywords as keys? That would be even better.
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my $str = " FOO=123 BAR=456 BAZ=789";
my @arr = split(/ ([A-Z]+)=/, $str);
# You have to start at index 1 because index 0 is everything
# before the first regex match
my %stuff = @arr[1 .. $#arr];
print Dumper \%stuff;