..and if
Memoize won't work in your particular instance (returning values from a database, for example), you could perhaps call
getinfo() outside of your routines A & B:
my ($name, $address, $other, $info, $here) = getinfo();
...
sub routine_A
{
...
print $name;
}
...
or, depending on your architecture, store the values temporarily somewhere, perhaps in an instance variable or similar.
For example if you don't know/ care which of routines A & B get called first, something like this might be helpful (which does unfortunately use a lexical global):
my @vars;
sub routine_A
{
...
if (!@vars) { @vars = getinfo() }
my $name = $vars[0];
print $name;
}
sub routine_B
{
...
if (!@vars) { @vars = getinfo() }
my $address = $vars[1];
print $address;
}
That way you're only calling getinfo() once, and then only if needed. Really, your chosen solution will depend a lot on whether you have access to the internals of getinfo(), whether getinfo() can be memoized, and the architecture surrounding these few functions.
Update: (still coming off the meds). Of course this sort of caching is what Memoize is for.. I wrote this under the impression that getinfo() might be called elsewhere in the code, not just directly in this subset of functions. Essentially though you'll want to cache the returned values somewhere outside of the routines.