For the anon subroutine to access each key at its | the subroutine's runtime, it needs to create a closure over a lexical variable (not, of course, access the global $_ variable) when the subroutine is created. Try something like (untested):
Basically, all the $_ scalars become $k scalars.for my $k (keys %{$self->{SQL}}) { ...; $self->{"f$k"} = sub { ...; $self->{$k}->execute(@_); while (my $dbrow = $self->{$k}->fetchrow_ +hashref()) { ...; } return ...; }; }
Give a man a fish: <%-{-{-{-<
In reply to Re: naming anonymous subroutines inner variables
by AnomalousMonk
in thread naming anonymous subroutines inner variables
by writch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |