Help for this page

Select Code to Download


  1. or download this
    {   my %h = ( x=>5, y=>8 );
        while ( my ($r,$s) = each %h ) {
            ...
        }
    }
    
  2. or download this
    for ({ x=>5, y=>8 }) {
        while ( my ($r,$s) = each %$_ ) {
            ...
        }
    }
    
  3. or download this
    for (paired( x=>5, y=>8 )) {
        my ($r,$s) = @$_;
        ...
    }
    
  4. or download this
    sub paired {
        my @pairs;
        push @pairs, [ shift, shift ] while @_;
        return @pairs;
    }
    
  5. or download this
    paired {
        my ($r,$s) = @_;
        ...
    } ( x=>5, y=>8 );
    
  6. or download this
    sub paired(&@) {
        my $cb = shift;
    ...
        push @rv, $cb->(shift, shift) while @_;
        return @rv;
    }