What you are thinking of is some kind of a closure, like this:
my $make_output = sub {
my ($Registration, $Rank) = @_;
return @{ $Data{$Registration}->{Name} }[$Rank], "\t";
};
print $make_output->($Registration1, $Rank1),
$make_output->($Registration2, $Rank2);
Though I guess that you might be able to simplify your code by using techniques such as OO.
Update: The following code shows what an OO variant would look like. Maybe you are trying to do something completely different; but according to your short line of code, I imagine that you could probably use this example.
my $data = Data->new( ... );
print $data->make_output($Registration1, $Rank1),
$data->make_output($Registration2, $Rank2);
# class definition
package Data;
sub new {
# set up data object
# ...
}
sub make_output {
my ($self, $Registration, $Rank) = @_;
return @{ $self->{$Registration}->{Name} }[$Rank], "\t";
}
|