#! /usr/local/bin/perl # seq # # Started by Eric Weeks, 1-29-94 (taken from shell.pl in ~/bin/src) # idea stolen from "AWK" book, basically I convered their program into # perl. Only bonus is that now it is more self-contained, and also # allows funky "seq e w" usage. # require "getopts.pl"; &Getopts('h'); # will set $opt_h to 1, if -h is included ($opt_h eq "") || die "Usage:\tseq 7 : 1 2 3 4 5 6 7\n", "\tseq 3 8 : 3 4 5 6 7 8\n", "\tseq 3 2 9 : 3 5 7 9\n", "\tseq e j : e f g h i j\n"; if ($#ARGV == 0) { foreach $i (1 .. $ARGV[0]) { print $i, "\n"; } } elsif ($#ARGV == 1) { foreach $i ($ARGV[0] .. $ARGV[1]) { print $i, "\n"; } } elsif ($#ARGV == 2) { for ($i = $ARGV[0]; $i <= $ARGV[2]; $i += $ARGV[1]) { print $i, "\n"; } } else { die "Usage:\tseq 5 : 1 2 3 4 5\n", "\tseq 3 8 : 3 4 5 6 7 8\n", "\tseq 3 2 9 : 3 5 7 9\n", "\tseq e j : e f g h i j\n"; }