4e3296e4964cf9749fd4229e1148e6030b8ddce1
[migration-tools.git] / extract_loadset
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use open ':utf8';
5
6 use Getopt::Long;
7
8 my $conf  = {}; # configuration hashref
9 initialize($conf);
10
11 open FP, '<', shift or die "Can't open input file: $!\n";
12
13 while (<FP>) {
14     my ($lead,$sub) = split /\t/;
15     print $sub if $sub > 6999999)
16 }
17
18 sub initialize {
19     my ($c) = @_;
20     my @missing = ();
21
22     # set mode on existing filehandles
23     binmode(STDIN, ':utf8');
24
25     my $rc = GetOptions( $c,
26                          'filter|f=i'
27                          'output|o=s',
28                          'help|h',
29                        );
30     show_help() unless $rc;
31     show_help() if ($c->{help});
32
33     my @keys = keys %{$c};
34     show_help() unless (@ARGV and @keys);
35     for my $key ('output', 'filter')
36       { push @missing, $key unless $c->{$key} }
37     if (@missing) {
38         print "Required option: ", join(', ', @missing), " missing!\n";
39         show_help();
40     }
41 }
42
43 sub show_help {
44     print <<HELP;
45 Usage is: extract_loadset [ARGS] INPUTFILE
46
47   --filter  -f  Record ID lower bound for 
48   --output  -o
49 HELP
50 exit;
51 }