#!/usr/bin/perl -w

use strict;

sub syntax_error {
	print STDERR "syntax: $0 [+-]start [+-]end\n";
	exit 1;
}

@ARGV == 2 or syntax_error();

my ($start, $end) = @ARGV;

my ($chop_start, $chop_end);

if ($start =~ s/^\+//) {
	$chop_start = "tail -n +".($start+1);
} elsif ($start =~ s/^\-//) {
	$chop_start = "tail -n $start";
} else {
	syntax_error();
}

if ($end =~ s/^\+//) {
	$chop_end = "head -n $end";
} elsif ($end =~ s/^\-//) {
	$chop_end = "dock $end";
} else {
	syntax_error();
}

# print STDERR "$chop_end | $chop_start\n";

exec "$chop_end | $chop_start";
die "cannot exec";
