|
Posted by Joost Diepenmaat on March 6, 2008, 9:36 pm
Please log in for more thread options
> Oh, thanks! It's "pass by reference"... But in my specific case that the
> subroutine "Label" is called in this way, is $sorted_features passed
> and $notes[0] returned?
Yes. But you've got some syntax problems.
> 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.
Well, what do you want to do with it?
>
> if ($sorted_features) {
> $panel->add_track($sorted_features,
This passes $sorted_features to the add_track method. You're also
missing a closing parenthesis here (or later): you probably want
$panel->add_track($sorted_features),
^-- close parenthesis
> $panel->add_track(-label => \&Label,);
this passes a reference to the Label subroutine to the add_track
method. I'm not sure if that's what you want. In any case, this
construct does *not* call the Label subroutine (though add_track may
call it later).
> sub Label
> {
> my $feature = shift;
>
> my @notes;
> foreach (qw(product result))
> {
> next unless $feature->has_tag($_);
> @notes = $feature->each_tag_value($_);
> last;
> }
> $notes[0];
> }
Whenever (if ever) Label is called, it will return $notes[0].
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
|