use String::TagString;
# Parse a string into a set of tags:
my $tags = String::TagString->tags_from_string($string);
# Represent a set of tags as a string:
my $string = String::TagString->string_from_tags($tags);

Also, it parses strings of "tags" into hashrefs, so you can tag whatever junk you want with strings.

A set of tags is an unordered set of simple strings, each possibly associated with a simple string value. This library parses strings of these tags into hashrefs, and turns hashrefs (or arrayrefs) back into these strings.

This string:

my $string = q{ beef cheese: peppers:hot };

Turns into this hashref:

my $tags = {
beef => undef,
cheese => '',
peppers => 'hot',
};

That hashref, of course, would turn back into the same string -- although sorting is not guaranteed.

This will either return a hashref of tags, as described above, or raise an exception. It will raise an exception if the string can't be interpreted, or if a tag appears multiple times with conflicting definitions, like in these examples: