Permalink
Browse files

change $news to be a singleton0ish value

  • Loading branch information...
1 parent cb59bba commit df90303a41831f566270c6658faf82acf0cdfc27 @szabgab committed Jan 25, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/PEG.pm
View
13 lib/PEG.pm
@@ -4,9 +4,13 @@ use Encode qw(decode);
use XML::RSS;
our $VERSION = '0.1';
+my $news;
sub _read_news {
- YAML::LoadFile(path config->{appdir}, 'data', 'news.yml');
+ if (not $news) {
+ $news = YAML::LoadFile(path config->{appdir}, 'data', 'news.yml');
+ }
+ return $news;
}
my $upcoming_events = YAML::LoadFile(
@@ -15,7 +19,6 @@ my $upcoming_events = YAML::LoadFile(
my $earlier_events = YAML::LoadFile(
path( config->{appdir}, 'data', 'earlier_events.yml' )
);
-my $news = _read_news();
# this will be refactored out into the templates later
# will use auto pages for this
@@ -91,7 +94,7 @@ my %content = (
title => 'News',
subtitle => 'News',
description => 'News about the Perl Ecosystem Group',
- news => $news,
+ news => _read_news(),
},
earlier_events => {
@@ -144,9 +147,7 @@ get '/rss' => sub {
}
);
- my $news = _read_news();
-
- foreach my $n (@$news) {
+ foreach my $n (@{ _read_news() }) {
my $text = $n->{text};
$text =~ s{"/}{"$url/}g;

0 comments on commit df90303

Please sign in to comment.