#!/usr/bin/perl -w

use strict;

my $nplots = 32;
my $sym = "6/mmm";

my $stream = $ARGV[0];

#system("~/crystfel/src/process_hkl -i ".$stream." -o test.hkl -y ".$sym);

open(FH, "test.hkl");
my $max = 0;
my $h;
my $k;
my $l;
my $line;
while ( $line = <FH> ) {

	chomp $line;

	if ( $line =~ /\s+(\d+)$/ ) {

		my $n = $1;
		if ( $n > $max ) {
			$line =~ /^\s+(\d+)\s+(\d+)\s+(\d+)\s+/;
			$h = $1;
			$k = $2;
			$l = $3;
			$max = $n;
		}

	}
}

printf("%i %i %i = %i\n", $h, $k, $l, $max);

exit 0;