#!/usr/local/bin/perl -w # # $Id: apply,v 1.2 2004/08/05 14:17:43 cwest Exp $ # # $Log: apply,v $ # Revision 1.2 2004/08/05 14:17:43 cwest # cleanup, new version number on website # # Revision 1.1 2004/07/23 20:09:59 cwest # initial import # # Revision 1.1 1999/02/27 03:36:18 abigail # Initial revision # # use strict; my ($VERSION) = '$Revision: 1.2 $' =~ /([.\d]+)/; sub usage () { require File::Basename; $0 = File::Basename::basename ($0); print < $argc} } # Now, apply the command till we run out. while (@ARGV && @ARGV >= $argc) { if (@thingies) { (my $new_command = $command) =~ s/${magic}(\d+)/$ARGV [$1 - 1]/ge; system $new_command; # Reinterpreted by the shell! splice @ARGV, 0, $argc; } else { if ($argc) { system $command, splice @ARGV, 0, $argc; } else { system $command; shift; } } } __END__ =pod =head1 NAME apply -- Run a command many times with different arguments. =head1 SYNOPSIS apply [-aB] [-#] command argument [argument ...] =head1 DESCRIPTION I runs the given command multiple times, with different arguments. Without arguments, I is run once for each argument. If the command contains strings of the form B<%d+>, the d'th next unused argument will be substituted. =head2 OPTIONS I accepts the following options: =over 4 =item -aB Use the character B instead of B<%> for interpolation of arguments. =item -# If an option of the form I<-#> is given, with I<#> a number, I uses that many arguments for each call of I. If I<-0> is given as an option, I is called without arguments, and it is called as many times as there are arguments following I on the command line. This option is ignored if I has magic B<%d+> sequences. =back =head1 ENVIRONMENT The working of I is not influenced by any environment variables. =head1 CAVEATS When I has magic B<%d+> sequences, the string after interpolation of the arguments is handed to a shell for interpretation of meta characters. This shell is determined by Perl, during its building phase, and is typically C on Unix platforms. =head1 BUGS I does not honor the users C<$SHELL> environment variable. =head1 REVISION HISTORY $Log: apply,v $ Revision 1.2 2004/08/05 14:17:43 cwest cleanup, new version number on website Revision 1.1 2004/07/23 20:09:59 cwest initial import Revision 1.1 1999/02/27 03:36:18 abigail Initial revision =head1 AUTHOR The Perl implementation of I was written by Abigail, I. =head1 COPYRIGHT and LICENSE This program is copyright by Abigail 1999. This program is free and open software. You may use, copy, modify, distribute and sell this program (and any modified variants) in any way you wish, provided you do not restrict others to do the same. =cut