$str = fraction($str) if ($str =~ /\d+_\d+/); #### $str = fraction($str); ... sub fraction { my $str = shift; if ($str =~ /\d+_\d+/) { # convert $str to fraction using mimetex syntax } return $str; } #### if ($str =~ /\d+_\d+/) { $str = fraction($str) } elsif ( condition 2 ) { action 2 } else { default } #### $str = fraction($str) if ($str =~ /\d+_\d+/) #### convert_ratio_to_decimal( \$str ); #### sub convert_ratio_to_decimal (\$) { ..... }; convert_ratio_to_decimal( $str ); #### $obj->convert_ration_to_decimal(); #### $error->logBadDateError( $str ) if (ErrorTracking::invalidDate( $str )) #### $varName = qr(regex goes here); if ( $str =~ /$UnderscoredNumber/ ) ... # poor if ( $str =~ /$SimpleRatio/ ) ... # good if ( $str =~ /$Ratio::simpleFraction/ ) ... # better