On Sun, 2010-04-04 at 00:07 -0400, Greg Larkin wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Gary Kline wrote: > > guys, > > > > i'm finally trying to get my private scripts and binaries in > > ~/bin in order. several of my perl scripts were meant to be > > throwaway ... but a few seem to be more useful and i would have > > to have informational or usage{} type messages. > > > > if a .pl script has to have at least one arg, is there an easy > > way to do that? can i have a perl fn called usage() that would > > be fed various strings? > > > > tia, > > > > gary > > > > > > > > Hi Gary, > > Check out this Perl module that builds on Getopt::Long, but also > includes support for echoing usage messages for each option: > http://search.cpan.org/~rjbs/Getopt-Long-Descriptive-0.085/lib/Getopt/Long/Descriptive.pm > > Hope that helps, > Greg
thanks for your url as well and the others to posted. but it seems like overkill since i dont need any explicit option or argument. i just need the script to tell me whether i have an arg or not. following is something i've kept in one of my junk drawers from when i was learning to write bourne sscripts. it uses the "$[token]" syntax that determines whether there are Any args on the cmdline. if not, the script prints a message and exits. #!/bin/sh if [ $# -eq 0 ] then echo "No args; need filename." else echo "$1" fi After a couple hours experimentation, the following does the same for my perl scripts: #!/usr/bin/perl $argc = @ARGV; if (! $argc ) { printf("No args; need filename.\n"); } else { printf("%s\n", @ARGV); } gary _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"