Argv

Provides an OO interface to an arg vector
Download

Argv Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David Boyce
  • Publisher web site:
  • http://search.cpan.org/~dsb/

Argv Tags


Argv Description

Provides an OO interface to an arg vector Argv is a Perl module that provides an OO interface to an arg vector.SYNOPSIS use Argv; # A roundabout way of getting perl's version. my $pl = Argv->new(qw(perl -v)); $pl->exec; # Run /bin/cat, showing how to provide "predigested" options. Argv->new('/bin/cat', , @ARGV)->system; # A roundabout way of globbing. my $echo = Argv->new(qw(echo M*)); $echo->glob; my $globbed = $echo->qx; print "'echo M*' globs to: $globbed"; # A demonstration of head-like behavior (aborting early) my $maxLinesToPrint = 5; my $callback = sub { print shift; return !(--$maxLinesToPrint); }; my $head = Argv->new('ls', ); $head->readonly("yes"); $head->pipe($callback); # A demonstration of the builtin xargs-like behavior. my @files = split(/s+/, $globbed); my $ls = Argv->new(qw(ls -d -l), @files); $ls->parse(qw(d l)); $ls->dbglevel(1); $ls->qxargs(1); my @long = $ls->qx; $ls->dbglevel(0); print @long; # A demonstration of how to use option sets in a wrapper program. @ARGV = qw(Who -a -y foo -r); # hack up an @ARGV my $who = Argv->new(@ARGV); # instantiate $who->dbglevel(1); # set verbosity $who->optset(qw(UNAME FOO WHO)); # define 3 option sets $who->parseUNAME(qw(a m n p)); # parse these to set UNAME $who->parseFOO(qw(y=s z)); # parse -y and -z to FOO $who->parseWHO('r'); # for the 'who' cmd warn "got -y flag in option set FOOn" if $who->flagFOO('y'); print Argv->new('uname', $who->optsUNAME)->qx; $who->prog(lc $who->prog); # force $0 to lower case $who->exec(qw(WHO)); # exec the who cmd Requirements: · Perl


Argv Related Software