my $variable = $number =~ m/(9*0*)/; my $ref = \$variable; ... if ($$ref){ ... }