Ricardo SIGNES > String-TagString-0.003 > String::TagString



Annotate this POD

View/Report Bugs
Module Version: 0.003   Source   Latest Release: String-TagString-0.005


  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);


String::TagString enables Web 2.0 synergy by deconstructing and synthesizing folksonomic nomenclature into structured dynamic programming ontologies.

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.

Tag String Syntax

Tag strings are space-separated tags. Tag syntax may change slightly in the future, so don't get too attached to any specific quirk, but basically:

A tag is a name, then optionally a colon and value.

Tag names can contains letters, numbers, dots underscores, and dashes. They can't start with a dash, but they can start with an at sign.

A value is similar, but cannot start with an at sign.

Alternately, either a tag or a value can be almost anything if it enclosed in double quotes. (Internal double quotes can be escaped with a backslash.)



  my $tag_hashref = String::TagString->tags_from_string($tag_string);

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:

  foo foo:

  foo:1 foo:2


  my $string = String::TagString->string_from_tags( $tag_set );

This method returns a string representing the given tags. $tag_set may be either a hashref or arrayref. An arrayref is treated like a hashref in which every value is undef.

Tag names and values will only be quoted if needed.


Ricardo Signes, <rjbs@cpan.org>


Please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Copyright 2006 Ricardo Signes, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: