Help for this page

Select Code to Download


  1. or download this
    sub make_closure {
       my ($str) = @_;
    ...
    say $sub->();   # 'hi'
    $str = 'hello';
    say $sub->();   # 'hi'
    
  2. or download this
    my $str = 'hi';
    my $sub = eval qq{ sub { "\Q$str\E" } } or die $@;
    ...
    say $sub->();   # 'hi'
    $str = 'hello';
    say $sub->();   # 'hi'