use constant foo => do { my $foo; # do something that is really hard to lookup or calculate $foo; # return of the do }; #### if (foo) { } else { }