Help for this page

Select Code to Download


  1. or download this
    sub toggle {
      my @states = @_;
    ...
        return $states[ $index++ % ( scalar @states ) ];
      }
    }
    
  2. or download this
    my $t = &toggle qw( alfa beta gamma );
    print &$t(), "\n" foreach ( 1 .. 20 );
    
  3. or download this
    sub curry {
        my ( $fnc, @arguments ) = @_;
    ...
            return &$fnc( @arguments, @_ );
        }
    }
    
  4. or download this
    sub echo {
        return join( " ", @_ );
    }
    
  5. or download this
    my $boss = &curry( \&echo, "My", "boss:" );
    my $friend = &curry( \&echo, "Johnny:" );
    
    print &$boss qw( has pointy hair ), "\n"; # "My boss: has pointy hair
    print &$friend qw( likes rock and roll ), "\n"; # etc.