Help for this page

Select Code to Download


  1. or download this
    $ perl -le '
    > %h = map ( $_, 2 * $_ ), 1 .. 3;
    > print qq{$_ - $h{$_}} for sort {$a <=> $b} keys %h;'
    0 - 
    $
    
  2. or download this
    $ perl -le '
    %h = map @$_, map [ $_, 2 * $_ ], 1 .. 3;
    ...
    2 - 4
    3 - 6
    $
    
  3. or download this
    $ perl -le '
    %h = map sub { return ( $_, 2 * $_ ) }->( $_ ), 1 .. 3;
    ...
    2 - 4
    3 - 6
    $
    
  4. or download this
    $ perl -le '
    %h = map { $_, 2 * $_ } 1 .. 3;
    ...
    2 - 4
    3 - 6
    $
    
  5. or download this
    $ perl -le '
    %h = map ( ( $_, 2 * $_ ), 1 .. 3 );
    ...
    2 - 4
    3 - 6
    $
    
  6. or download this
    $ perl -le '
    > %h = map do { ( $_, 2 * $_ ) }, 1 .. 3;
    ...
    2 - 4
    3 - 6
    $