What exactly do this code snippet?
...
method go() {
my %args;
while ( ref( $_[0] ) eq 'HASH' ) {
%args = ( %args, %{ shift(@_) } );
}
....
}
Taken from a Moose based package…
While the first argument is a hashref, do what? (with the shifted out hashref?)
I understand shift(@_) simply dont understand what’s mean the
%hash = (%hash, %{$hashref});
While the first element of
@_is a reference to a hash, add the contents of that hash reference to the hash%argsand remove the reference from@_. In other words, consolidate all of the initial hash arguments into a single hash.%a = (%a, %b)for some pair of hashes%aand%bis analogous to@a = (@a, @b)for some pair of arrays@aand@b, joining@aand@binto a single list and assigning the result back to@a. For arrays, there is of course a shorthandpush @a, @bfor just this purpose.