I am struggeling with Class::DBI. When the program runs I get this error:

Can't locate object method "kontakte" via package "Customercare::Kundenkontakte" at cc.pl line x.

What I really want is find a list of customer which had contact with my company. Like this:

01. Libary X
talk
postcard

02. Library Y
postcard

But I thought it's better to retrieve that list by asking for the contacts first. Can you help me?
Thanks,
Horshack

#!/usr/bin/perl use strict; # Buechereien -> german for Libraries # Kundenkontakte -> german for customer-contacts # use Customercare::Buechereien; use Customercare::Kundenkontakte; my @kk = Customercare::Kundenkontakte->retrieve_all; my $i = 0; foreach (@kk) { last if $i++ > 10; printf "%02d. %s\n", $i, $_->customer->plzort; # This is where the problem occurs: foreach ( $_->kontakte ) { printf " %s\n", $_->aktion_kurz; } } package Customercare::Buechereien; use strict; use base 'Customercare::DBI'; __PACKAGE__->set_up_table("buechereien"); __PACKAGE__->has_many( # This will create a new Method named "kontakte" "kontakte", 'Customercare::Kundenkontakte' => "customer"); 1; package Customercare::Kundenkontakte; use strict; use base 'Customercare::DBI'; __PACKAGE__->set_up_table("kundenkontakte"); __PACKAGE__->has_a( customer => 'Customercare::Buechereien' ); 1; These are the tabledefinitions: CREATE TABLE buechereien ( customer varchar(50) NOT NULL default '', anschrift1 varchar(100) default NULL, plzort varchar(100) default NULL, tel varchar(50) default NULL, PRIMARY KEY (customer) ) TYPE=MyISAM; CREATE TABLE kundenkontakte ( lfdnr int(11) NOT NULL auto_increment, customer varchar(50) NOT NULL default '', aktion_kurz varchar(50) NOT NULL default '', PRIMARY KEY (lfdnr) ) TYPE=MyISAM;

In reply to has_many in Class:DBI by horshack

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.