Author image J. Shirley
and 1 contributors


DBIx::Class::Tokenize - Automatically tokenize a column on creation


This component simply creates a clean token based on a field on insertion. The simple use case is having a long name that is displayable, like "Catalyst Book" that you want to change to "catalyst_book". Rather than do that by hand every time you create a record, this component does it for you.


 package MyApp::Schema::Book;

 __PACKAGE__->load_components( qw(Tokenize ... Core) );
     id   => { data_type => 'integer', is_auto_increment => 1 },
     name => { data_type => 'varchar', size => 128, 
        # Update the 'token' field on create
        token_field => 'token' },
     token => { data_type => 'varchar', size => 128, is_nullable => 0 }


 my $row = $schema->resultset('Book')->create({ name => "Catalyst Book" });
 print $row->token; # Prints "catalyst_book



This method is what performs the actual conversion to the tokenized form. It is easy to override so that you can change things around to suit your particular table. Whatever is returned is inserted into the configured token_field.

An example of extending this method would be to traverse a tree in a row that uses DBIx::Class::Tree::AdjacencyList and tokenize the parents as well.


J. Shirley, <jshirley at>


Please report any bugs or feature requests to bug-catalyst-controller-rest-dbi c-item at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc DBIx::Class::Tokenize

You can also look for information at:


This is a Cold Hard Code, LLC module -


Copyright 2008 Cold Hard Code, LLC, all rights reserved.

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