http://www.perlmonks.org?node_id=62520
Category: Win32 Stuff
Author/Contact Info Drake Wilson (premchai21; drake@libcom.com)
Description: A short script that simply takes a program and runs it with a few different sets of arguments.
#!/usr/bin/perl

my ($sep,$num,@prog,@each);
die "Too few arguments -- for help, try $0 ?\n" if ((@ARGV < 3) && ((@
+ARGV < 1) || ($ARGV[0] !~ /\?|h/)));
$num=shift @ARGV;
print <<MUMBLE if ($num =~ /\?|h/);
Usage: $0 # / p / a /
where # is the number of arguments to take at a time,
      / is any string, used as a separator,
      p is the first part, usually the program name, of each command l
+ine, and
      a is the list of arguments for p.

For example: $0 1 / unzip / foo bar baz /
will execute:
unzip foo
unzip bar
unzip baz

Or: $0 2 / someprog -osz / these are some args /
will execute:
someprog -osz these are
someprog -osz some args
MUMBLE
die "\n" if ($num =~ /\?|h/);
$sep=shift @ARGV;
{
    my $tmp;
    push @prog, $tmp while (($tmp = shift @ARGV) && $tmp ne $sep);
    push @each, $tmp while (($tmp = shift @ARGV) && $tmp ne $sep);
}
while (@each)
{
    my @here;
    foreach (1..$num) { push @here, shift @each; }
    system(@prog,@here);
}