my $o_regex = qr{ethernet0/[0-2]}; my $test = defined($o_noreg) ? $$resultat{$key} eq $o_descr : $$resultat{$key} =~ m/$o_regex/;