#!/usr/bin/env perl use strict; use warnings FATAL => 'all'; my $version = shift or die "no version specified!"; my $changelog = shift or die "no changelog file specified!"; open my $fh, '<', $changelog or die "can't open $changelog: $!"; my $context; my $found_version; while (my $line = <$fh>) { if ($found_version) { last if $line =~ /^\S/; $context++; } elsif ($line =~ /^v?\Q$version\E/) { $found_version = 1; } } close $fh; die "couldn't find heading for $version!" unless $found_version; print "$context\n";