gnu style args
[p5sagit/Distar.git] / helpers / changelog-context
CommitLineData
c1a1a773 1#!/usr/bin/env perl
2use strict;
3use warnings FATAL => 'all';
4
5my $version = shift or die "no version specified!";
6my $changelog = shift or die "no changelog file specified!";
7
8open my $fh, '<', $changelog
9 or die "can't open $changelog: $!";
10my $context;
11my $found_version;
12while (my $line = <$fh>) {
13 if ($found_version) {
14 last
15 if $line =~ /^\S/;
16 $context++;
17 }
18 elsif ($line =~ /^v?\Q$version\E/) {
19 $found_version = 1;
20 }
21}
22close $fh;
23die "couldn't find heading for $version!"
24 unless $found_version;
25
26print "$context\n";