{ my $lock = lock_something(); # lock released on scope exit do_stuff_that_needs_the_lock(); }