use strict; my @x = somefunction(); for (@x) { *{; no strict 'refs'; \*$_} = sub { # ... }; }