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