"Perl Programmers Reference Guide (англ.) (программ.) /19.12.1998/ " - читать интересную книгу автора interchangeable, that's not the case for hashes. Just
because you can subscript a list value like a normal array does not mean that you can subscript a list value as a hash. Likewise, hashes included as parts of other lists (including parameters lists and return lists from functions) always flatten out into key/value pairs. That's why it's good to use references sometimes. It is often more readable to use the => operator between key/value pairs. The => operator is mostly just a more visually distinctive synonym for a comma, but it also arranges for its left-hand operand to be interpreted as a string--if it's a bareword that would be a legal identifier. This makes it nice for initializing hashes: %map = ( red => 0x00f, blue => 0x0f0, green => 0xf00, ); or for initializing hash references to be used as records: $rec = { witch => 'Mable the Merciless', date => '10/31/1776', }; or for using call-by-named-parameter to complicated functions: 18 perl 5.005, patch 02 14/Jun/98 PERLDATA(1) Perl Programmers Reference Guide PERLDATA(1) $field = $query->radio_group( name => 'group_name', values => ['eenie','meenie','minie'], default => 'meenie', linebreak => 'true', labels => \%labels |
|
|