According to the Perl docs, the =>
operator in list context is equivalent to a comma with extra quoting powers. That much I understand, but the docs also state
The => operator is helpful in documenting the correspondence between keys and values in hashes, and other paired elements in lists.
They give this example:
login( $username => $password );
Now, to me that seems equivalent to
login($username, $password)
Is there any other difference apart from the implicit quoting between the two? Are the two parameters passed to login()
linked somehow?
More importantly, what would be an example of "paired elements" in a list (not a hash)? If I define a list as
@f=("foo" => "bar")
can I somehow use foo
to access bar
? Does this somehow make the array associative?
I have read How does double arrow (=>) operator work in Perl? but that asks about how it is used in general not specifically in list context.