Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Syntax for casting map to a hash or an array

by cbeckley (Curate)
on Apr 05, 2017 at 15:28 UTC ( #1187140=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    return keys %{ {map { $_ => 1 } @_} };
    
  2. or download this
    say Dumper(\%{ {map { $_ => 'fish' } qw(one two red blue)} } );
                 ^ ^                                         ^ ^
                 |-|-----------------------------------------|-|
    
  3. or download this
    $VAR1 = {
              'blue' => 'fish',
    ...
              'red' => 'fish',
              'two' => 'fish'
            };
    
  4. or download this
    Ambiguous use of %{map{...}} resolved to %map{...}
    
  5. or download this
    $VAR1 = [
              'one',
    ...
              'blue',
              'fish'
            ];
    
  6. or download this
    say Dumper(\@{ {map { $_ => 'fish' } qw(one two red blue)} } );
    
  7. or download this
    Not an ARRAY reference
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1187140]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2020-11-25 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?