Help for this page

Select Code to Download


  1. or download this
    my $sub = sub { my ($str) = @_; sub { $str } }->($str);
    
  2. or download this
    my $sub = sub { my $str = $str; sub { $str } }->();
    
  3. or download this
    my $sub = do { my $str = $str; sub { $str } };
    
  4. or download this
    my $str_copy = $str;
    my $sub = sub { $str_copy };
    
  5. or download this
    for my $str (...) {
       ... sub { ... $str ... } ...
    }
    
  6. or download this
    sub make_list_iterator { 
       my @list = @_;
    ...
    }
    
    my $iter = make_list_iterator(@list);