Help for this page

Select Code to Download


  1. or download this
    %hash = ( a => 1, b => 2, c => 3 );
    %hash = ( a => 1, b => 2, c => 3 );
    ...
    $t = @a;             # array in scalar context: number of items
    printf "\$s is \$t: %s\n\$s: %s\n\$t: %s\n", $s eq $t ? 'yes' : 'no', 
    +$s, $t;
    printf "\$s is \$t: %s\n", $s eq $t ? 'yes' : 'no';
    
  2. or download this
    %hash = ( a => 1, b => 2, c => 3 );
    $s = %hash;        # scalar context: hash stats
    ...
    my @a = %hash;     # list context: key/value pairs
    $t = @a;           # array in scalar context: number of items
    printf "\$s is \$t: %s\n\$s: %s\n\$t: %s\n", $s eq $t ? 'yes' : 'no', 
    +$s, $t;