http://qs321.pair.com?node_id=1166302


in reply to Re: naming anonymous subroutines inner variables
in thread naming anonymous subroutines inner variables

Didn't do anything except make the value that fails $self->{$k} instead of $self->{$_}.
  • Comment on Re^2: naming anonymous subroutines inner variables

Replies are listed 'Best First'.
Re^3: naming anonymous subroutines inner variables
by zwon (Abbot) on Jun 22, 2016 at 21:08 UTC
    Works for me:
    #!/usr/bin/env perl use 5.014; use strict; use warnings; my $self; for my $k (qw(foo bar baz)) { $self->{$k} = sub { return join $k, @_ }; $self->{"f_$k"} = sub { my $self = shift; return $self->{$k}->(@_); }; } for my $k (qw(foo bar baz)) { say $self->{"f_$k"}->($self, qw(a b c)); } __END__ afoobfooc abarbbarc abazbbazc
    It would be more productive if you would show something we could actually run.