|
Posted by Rose on March 7, 2008, 12:00 am
Please log in for more thread options
> Label returns $notes[0], yes. Whether, when, and with what arguments
> Label is called, and what happens to that return value, are completely
> under the control of the $panel object: that's the point of passing it
> in, so the object can call it if it wants to. In this case I'd think
> it's unlikely it would be called with $sorted_features, but I
> couldn't tell without knowing what sort of object $panel is.
>
>> The problem is that I'd like to call Label (the codes of Label can't
>> be modified) but don't know how to receive its outputs.
>
> I'm not sure exactly what you are trying to achieve, here. You can call
> Label, yourself, with any arguments, and do what you like with the
> return value; this is completely independant of the fact you have also
> passed it into $panel->add_track. Can you post a *short* complete script
> we can all run, and explain how it isn't doing what you want?
>
> Ben
>
Although Label returns $notes[0], but it in turn depends on
$feature->each_tag_value($_); from where $feature is "shifted" in. I'm
unable to post a short complete script here because reproducing the
hierarchy of the data is impossible. Therefore my focus is try to understand
how to use the codes invented instead of reinventing the wheel.
That's the reason why I care about what is really passed into Label because
I have to ensure my object is in the correct structure to pass. In this
case, is $sorted_features shifted into Label? Or it depends on
add_track behaviour?
if ($sorted_features) {
$panel->add_track($sorted_features, -label => \&Label,);
}
sub Label
{
my $feature = shift;
my @notes;
foreach (qw(product result))
{
next unless $feature->has_tag($_);
@notes = $feature->each_tag_value($_);
last;
}
$notes[0];
}
|