summaryrefslogtreecommitdiff
path: root/img/dist/IM/dot.im/get.sbr
blob: 15a3194add27470af9c4801506c5822945cb33f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*-Perl-*-

# A user customizable subroutine for imget.
# 'get_sub' is called if "GetSbr=get.sbr" is specified in your "Config".
# The argments are the folder name, the start of the range, and the end
# of the range.

%hash = ();

sub get_sub ($$$) {
    my ($folder, $first, $last) = @_;

    my $dir = expand_path($folder);
    my ($name, $val);

    open(SEQ, "$dir/.mh_sequences") || return;

    while (<SEQ>) {
	chomp;
	($name, $val) = split(': ');
	$hash{$name} = $val;
    }

    close(SEQ);

    if (defined($hash{'unseen'})) {
	if ($first == $last) {
	    $hash{'unseen'} .= " $first";
	} else {
	    $hash{'unseen'} .= " $first-$last";
	}

	open(SEQ, ">$dir/.mh_sequences");

	foreach (keys %hash) {
	    print SEQ "$_: $hash{$_}\n";
	}

	close (SEQ);
    }
}

1;