The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#! /usr/bin/perl -w

# Toby Thurston -- 02 Nov 2017

use strict;
use warnings;
use List::Util qw/min/;

my $source = shift;
open my $ostn_fh, '<', $source or die "Can't open $source: $!\n";
my $header = <$ostn_fh>;

my @ee;
my @nn;

while (my $line = <$ostn_fh>) {
    chomp($line);
    my ($id, $easting, $northing, $e_shift, $n_shift, $h_shift, $datum) = split ',', $line;
    push @ee, int $e_shift * 1000;
    push @nn, int $n_shift * 1000;
}

my $min_e = min @ee;
my $min_n = min @nn;

my $count = scalar @ee;
open my $east_fh, '>', "ostn_east_shift_$min_e" ;
print $east_fh pack("S<[$count]", map { $_ - $min_e } @ee);
close $east_fh;

$count = scalar @nn;
open my $north_fh, '>', "ostn_north_shift_$min_n";
print $north_fh pack("S<[$count]", map { $_ - $min_n } @nn);
close $north_fh;