#!/usr/bin/perl

# This is code which splits up a patch hunk by hunk
# Useful for things like finding out which small part of a big patch
# actually fixes the problem in question
$hunk = 0;
$head = "";

while(<>) {
    if(/^\@\@/) {
        $hunk++;
	if(hunk > 1) {
	    close(F);
	    }
        open(F,"> hunk$hunk") || die "$!";
	print F $head;
	}
    if($hunk > 0) {
        print F $_;
	}
    else {
        $head .= $_;
	}
    }
