summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRuss Allbery <rra@cpan.org>2021-09-06 19:03:41 -0700
committerRuss Allbery <rra@cpan.org>2021-09-06 19:03:41 -0700
commit1b42e85be09c5759aa56af82bd8ffefc5f78d275 (patch)
treeb62e52e31f57c06eeb5a565043ef4e2aec5cb5a0 /lib
parenta6cb31e2652cf142046e3cf3d430cf44771739e3 (diff)
Move RSS data into spin module state
Move @RSS into module state and initialize it to an empty list to simplify some code. Take advantage of the new syntax possible with current versions of Perl.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/App/DocKnot/Spin.pm22
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/App/DocKnot/Spin.pm b/lib/App/DocKnot/Spin.pm
index d22bbaf..614fec8 100755
--- a/lib/App/DocKnot/Spin.pm
+++ b/lib/App/DocKnot/Spin.pm
@@ -42,8 +42,8 @@ my $URL = 'https://www.eyrie.org/~eagle/software/web/';
use strict;
use subs qw(expand parse parse_context);
use warnings;
-use vars qw($FILE @FILES $FULLPATH $ID $OUTPUT
- @RSS %SITEDESCS %SITELINKS @SITEMAP
+use vars qw($FILE @FILES $FULLPATH $OUTPUT
+ %SITEDESCS %SITELINKS @SITEMAP
@STATE %VERSIONS %commands);
##############################################################################
@@ -848,13 +848,11 @@ sub do_heading {
$output .= qq( <link rel="stylesheet" href="$style");
$output .= qq( type="text/css" />\n);
}
- if (@RSS) {
- for my $rss (@RSS) {
- my ($url, $title) = @$rss;
- $output .= qq( <link rel="alternate" type="application/rss+xml");
- $output .= qq( href="$url"\n);
- $output .= qq( title="$title" />\n);
- }
+ for my $rss ($self->{rss}->@*) {
+ my ($url, $title) = $rss->@*;
+ $output .= qq( <link rel="alternate" type="application/rss+xml");
+ $output .= qq( href="$url"\n);
+ $output .= qq( title="$title" />\n);
}
if ($FILE ne '-') {
$output .= $self->sitelinks($file);
@@ -989,7 +987,7 @@ sub do_rss {
my ($self, $format, $url, $title) = @_;
$url = $self->parse($url);
$title = $self->parse($title);
- push (@RSS, [ $url, $title ]);
+ push($self->{rss}->@*, [$url, $title]);
return (1, '');
}
@@ -1192,6 +1190,7 @@ sub _spin {
$self->{id} = undef;
$self->{macros} = {};
$self->{out_fh} = $out_fh;
+ $self->{rss} = [];
$self->{space} = q{};
$self->{strings} = {};
@@ -1234,9 +1233,6 @@ sub _spin {
# Close open tags and print any deferred whitespace.
print {$out_fh} $self->border_clear(), $self->{space};
-
- # Clean up per-file data so that it's not carried to the next file.
- undef @RSS;
}
##############################################################################