use strict; use warnings FATAL => 'all'; use Test::More; sub distance { length $_[0]; } sub answer { $_ = $_[0]; return $1 + distance($_) if s/\(#:(\d+)\)/#/; } is( answer('Life, the universe & everything? (#:3) Huh?'), 42, ); done_testing;