3 use warnings FATAL => 'all';
4 use Getopt::Long qw(:config gnu_getopt);
6 "p|prefix=s@" => \(my $prefix = []),
7 "s|suffix=s@" => \(my $suffix = []),
8 ) or die "Error in command line arguments\n";
10 my $version = shift or die "no version specified!\n";
11 my $changelog = @ARGV ? shift : 'Changes';
15 open my $fh, '<:raw', $changelog
16 or die "can't open $changelog: $!\n";
19 while (my $line = <$fh>) {
23 $version_log .= $line;
25 elsif ($line =~ /^v?\Q$version\E/) {
30 die "couldn't find heading for $version in $changelog!\n"
31 unless $found_version;
33 $version_log =~ s/\r\n?/\n/g;
34 $version_log =~ s/\n+\z//;
37 for @$prefix, @$suffix;
39 print join("\n\n", @$prefix, $version_log, @$suffix) . "\n";