Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

by premchai21 (Curate)
on Mar 06, 2001 at 21:47 UTC ( #62520=sourcecode: print w/replies, xml ) Need Help??
Category: Win32 Stuff
Author/Contact Info Drake Wilson (premchai21;
Description: A short script that simply takes a program and runs it with a few different sets of arguments.

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
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; }
Replies are listed 'Best First'.
by merlyn (Sage) on Mar 06, 2001 at 21:59 UTC
      merlyn, are you running a popularity test with your links? :)
        Nope. I wanna see if what I'm saying is useful to people. And one way to do that more-or-less transparently is to know how many people clicked on a link, which my /cgi/go framework will tell me.

        Of course, it's been a long time since that URL actually fired off a separate process on my server: it's now a nice mod_perl handler very early in the Trans phase, but the URL is mnemonic enough that I stayed with it. {grin}

        For more details on what /cgi/go is and how to code it, see my WT column where I introduced it to my site.

        -- Randal L. Schwartz, Perl hacker

      Well what do you know -- there's a Perl version.

      And I thought xargs was only a Unix thing...

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://62520]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-08-18 22:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found