my $variable = sub {$number =~ m/(9*0*)/}; # ... if ($variable->()){ # ... }