diff --git a/lib/DDG/Goodie/Fortune.pm b/lib/DDG/Goodie/Fortune.pm index 654f247d061..b9078684a7e 100644 --- a/lib/DDG/Goodie/Fortune.pm +++ b/lib/DDG/Goodie/Fortune.pm @@ -16,13 +16,14 @@ attribution github => ['https://github.com/frncscgmz', 'frncscgmz']; zci is_cached => 0; zci answer_type => "fortune"; +my $ffile = share('fortunes'); +my $fortune_file = Fortune->new($ffile); +$fortune_file->read_header(); + handle remainder => sub { - my $ffile = share('fortunes'); - my $fortune_file = Fortune->new($ffile); - $fortune_file->read_header(); - my $output = $fortune_file->get_random_fortune(); - $output =~ s/\n//g; - return $output; + my $output = $fortune_file->get_random_fortune(); + $output =~ s/\n//g; + return $output; }; 1; diff --git a/t/Fortune.t b/t/Fortune.t index 6ea62913466..1cb3ad34cc7 100644 --- a/t/Fortune.t +++ b/t/Fortune.t @@ -9,12 +9,12 @@ zci answer_type => 'fortune'; zci is_cached => 0; ddg_goodie_test( - [qw( - DDG::Goodie::Fortune - )], - 'gimmie a fortune cookie' => test_zci(qr/.+/), + [qw( + DDG::Goodie::Fortune + )], + 'gimmie a fortune cookie' => test_zci(qr/.+/), 'gimmie a unix fortune' => test_zci(qr/.+/), - 'give me a fortune cookie!' => test_zci(qr/.+/), + 'give me a fortune cookie!' => test_zci(qr/.+/), 'give me a unix fortune!' => test_zci(qr/.+/), 'unix fortune cookie' => test_zci(qr/.+/), );