You might not even need an anonymous function if you want to run a block of code and there is zero or one input. You can use map
instead.
Just for the side effect:
map { print 1 } 1;
Transform data, take care to assign to a list:
my ($data) = map { $_ * $_ } 2;