Help for this page

Select Code to Download


  1. or download this
    use signatures;
    my $lamb = sub ($x, $y) { $x + $y };
    print( $lamb->(3,4), "\n" );  # 7
    
  2. or download this
    use signatures;
    my $lamb = sub ($x) { $x = 4 };
    my $y = 3;
    $lamb->($y);
    print("$y\n");  # 3  XXX want 4
    
  3. or download this
    sub (...) { ... }
    
  4. or download this
    sub { my (...) = @_; ... }
    
  5. or download this
    Lexical::Alias::alias(my $x, $_[0]);
    Lexical::Alias::alias(my $y, $_[1]);
    Lexical::Alias::alias(my $z, $_[2]);