In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Ken Williams) wrote:
> Another question - to add new entries to the address book, I think I do > something like this: > > my $person = $glue->make(new => 'person', with_properties => > {first_name => 'Foo', > last_name => 'Bar', > email => '[EMAIL PROTECTED]'}); > > When I do this, the first_name and last_name entries show up fine in > Address Book, but the email doesn't. I'm guessing this is because it's > an 'element' of a person and not a 'property', whatever that means > (what does that mean?). It means (among other things) that there can be more than one. One of the hacks in the new Panther Hacks book has exactly this in it. So go buy it! ;) Try this: my $person = $glue->make(new => 'person', with_properties => {first_name => 'Foo', last_name => 'Bar'}); $glue->make(new => 'email', at => location(end => $person->prop('emails')), with_properties => { value => '[EMAIL PROTECTED]', label => 'work', } ); In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Ken Williams) wrote: > Oh, and while I'm at it: > > I can't quite figure out how to change the values of an existing > Address Book record. I guess there are two cases: changing 'property' > values and changing 'element' values. Any examples I could get for > that would be great. First, get the person: my $person = $glue->obj(person => whose(AND => [first_name => equals => 'Foo'], [last_name => equals => 'Bar'] ) ); Properties are simple enough. You get like this: $person->prop('last_name')->get; And similarly, set like this: $person->prop('last_name')->set(to => 'Baz'); In the case of the email elements, emails property returns a list, and each element of the list is an email object, which you can then get and set with the value property. for my $email ($person->prop('emails')->get) { print $email->prop('value')->get; } To set: for my $email ($person->prop('emails')->get) { my $value = $email->prop('value'); (my $text = $value->get) =~ s/\@/[EMAIL PROTECTED]/; print $value->set(to => $text); } Hope that helps, -- Chris Nandor [EMAIL PROTECTED] http://pudge.net/ Open Source Development Network [EMAIL PROTECTED] http://osdn.com/