# Define many-to-many relationship between foo and bar tables
# using the foos_bars linking table
# in the database:
TABLE foo (
id INTEGER, something TEXT );TABLE bar (
id INTEGER, another_thing TEXT );TABLE foo_bar ( foo_id INTEGER, bar_id INTEGER );
# in Result/Foo.pm:
__PACKAGE__->many_to_many(
'bars', # name of the relationship you're creating in foo
'foos_bars', # name of the relationship in foo that points to the link table
'bar' # name of the relationship to bar on the link table
);
# in some nearby code:
@bars = $foo->bars;
CPAN docs