in reply to Re: Re: Passing a list to an Object
in thread Passing a list to an Object
The arguments don't get passed as a hash. '=>' doesn't automatically transform things into hashes, but instead is the equivalent of a comma, with the side effect of ensuring that the word before it is interpreted as a string. So it's the equivalent of saying:MyClass->doThat(chew=>'bananas')
Or even:MyClass->doThat('chew', 'bananas')
So it's a list, not a hash, and you don't need to worry about order getting scrambled. The list doesn't turn into a hash until you do something like:MyClass::doThat('MyClass', 'chew', 'bananas')
Then, you've copied the list into an associative array. Until then, plain-vanilla list... Sorry to flog a dead horse, but I saw a misconception waiting to happen...sub doThat { my $type = shift; my %input = @_; }
stephen
|
|---|