my ($from, $to) = (1, 3); my $x; $x = sub { my $i = shift; print "Inside recursive sub!\n"; $x->(++$i) if $i < $to; } and $x->($from);