1

I have a hash called

%values

Now I want to return the whole hash in a subroutine

sub getvalues {
  return $values;
}

But then I got an error, because $value needs a definition and my program stops. If I'm using

sub getvalues {
  return %values;
}

it seems to work, but my program is very slow and don't get further... So how can I return the whole map?

4

1 回答 1

1

返回哈希引用而不是哈希会很好,您需要做的是

首先将散列放入散列引用然后返回它

sub getvalues {

    my %values = (test => "SO");

    my $values = \%values;

    return $values;
  }
于 2013-07-10T05:34:32.520 回答