<commit_before>package DDG::Goodie::Pi;
# ABSTRACT: This Goodie returns 'pi' to a user-specified number of decimal places

use DDG::Goodie;

zci answer_type => "pi";
zci is_cached   => 1;

name "Pi";
primary_example_queries "pi 7";
description "Ex. returns 3.1415926";

code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Pi.pm";
attribution github => ["https://github.com/puskin94", "puskin94"],
            github => ["https://github.com/jmvbxx", "jmvbxx"];


triggers startend => "pi","π";


my $PI = '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679'.
		'8214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196'.
		'4428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273'.
		'724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609';

my $PI_max_digits = length($PI);

handle query_raw => sub {

    return unless $_ =~ /^(?:pi|π)?\s*(?:to|first)?\s*(\d+)\s*(?:(?:decimal|digit)s?)?\s*(?:of\s+(?:pi|π))?$/i && 
                        $1 > 0 && $1 < $PI_max_digits;

    my $answer = substr $PI, 0, ( $1 + 2 );
    return $answer,
    structured_answer => {
        input     => [],
        operation => ["First ".$1." digits of Pi"],
        result    => $answer
    };

};

1;
<commit_msg>used matching regex<commit_after>package DDG::Goodie::Pi;
# ABSTRACT: This Goodie returns 'pi' to a user-specified number of decimal places

use DDG::Goodie;

zci answer_type => "pi";
zci is_cached   => 1;

name "Pi";
primary_example_queries "pi 7";
description "Ex. returns 3.1415926";

code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Pi.pm";
attribution github => ["https://github.com/puskin94", "puskin94"],
            github => ["https://github.com/jmvbxx", "jmvbxx"];


triggers startend => "pi","π";


my $PI = '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679'.
		'8214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196'.
		'4428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273'.
		'724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609';

my $PI_max_digits = length($PI);

handle query_raw => sub {

    return unless $_ =~ /^(?:pi|π)?\s*(?:to|first)?\s*(?<decimal>\d+)\s*(?:(?:decimal|digit)s?)?\s*(?:of\s+(?:pi|π))?$/i && 
                        $+{decimal} > 0 && $+{decimal} < $PI_max_digits;

    my $answer = substr $PI, 0, ( $1 + 2 );
    return $answer,
    structured_answer => {
        input     => [],
        operation => ["First ".$+{decimal}." digits of Pi"],
        result    => $answer
    };

};

1;

{'fraction_non_alphanumeric': 0.15528596187175042, 'fraction_numerical': 0.2915077989601387, 'mean_word_length': 4.5606936416184976, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 26, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3352682', 'n_tokens_mistral': 1649, 'n_tokens_neox': 1131, 'n_words': 166}