Re: not-so-plain documentation
* Eric Wilhelm [EMAIL PROTECTED] [2004-06-25 05:11]: I've seen pod2usage() and this would work, but most of these scripts have some defaults set for variables that can be changed with the GetOptions flags and I'd like to show these defaults at least in the help message. You are looking for Pod::Constants. http://search.cpan.org/dist/Pod-Constants/ Regards, -- Aristotle If you can't laugh at yourself, you don't take life seriously enough.
Re: not-so-plain documentation
my $rounding = 0.01; GetOptions( 'round=f' = \$rounding, 'help' = sub {usage()}, ); sub usage { print usage: $0 filename\n; print options: --round float (default $rounding)\n; } END This will have a nasty side effect, as shown below: $ round --help usage: round filename options: --round float (default 0.01) $ round --round=42 --help usage: round filename options: --round float (default 42) -- Johan
Re: not-so-plain documentation
A. Pagaltzis wrote: * Eric Wilhelm [EMAIL PROTECTED] [2004-06-25 05:11]: I've seen pod2usage() and this would work, but most of these scripts have some defaults set for variables that can be changed with the GetOptions flags and I'd like to show these defaults at least in the help message. You are looking for Pod::Constants. Or even Scriptalicious... http://search.cpan.org/dist/Scriptalicious/ -- Sam Vilain, sam /\T vilain |T net, PGP key ID: 0x05B52F13 (include my PGP key ID in personal replies to avoid spam filtering)
Re: not-so-plain documentation
# The following was supposedly scribed by # Johan Vromans # on Friday 25 June 2004 03:00 am: This will have a nasty side effect, as shown below: $ round --round=42 --help usage: round filename options: --round float (default 42) Yes, this is correct. But I was planning something more along these lines: use Getopt::Long; my $all = 7; my $foo = bar; my @opt_build = ( ['a|all=i', \$all, value for all (default $all)], ['f|foo=s', \$foo, string for foo (default $foo)], ['h|help' , sub { usage()}, show this help message], ); my %opts = map({$_-[0] = $_-[1]} @opt_build); my @help = map({$_-[0] $_-[2]} @opt_build); GetOptions(%opts); sub usage { my $caller = $0; $caller =~ s#.*/##; die join(\n, usage:, $caller file, @help), \n; } END And, in my mythical modified version of perldoc, I'd need to run up to the point where @help is declared, then exit. Maybe instead of 'my @help=', we do 'Pod::Dynamic-usage(map({$_-[0] $_-[2]} @opt_build));' and that triggers an exit from the 'do()' (for instance when ($0 =~ m/perldoc/)), and declares main::usage() otherwise. Something along those lines anyway. --Eric -- Peer's Law: The solution to the problem changes the problem.
Re: not-so-plain documentation
# The following was supposedly scribed by # Randy W. Sims # on Thursday 24 June 2004 10:40 pm: You'll want to subclass Pod::Text, override the proper method to add a new escape sequence (say $variable_name), then maybe override the constructor to take a hash with the values for the variables or possibly something more elaborate like evaling the variable name in the caller's context. Yes. The trouble is that I don't want to have to manually re-generate the pods in any way, so I'll need a modified perldoc. (If you haven't chastised me for it before, I'm the guy who makes changes to the code directly on the production system:) My concept is that the script does something like 'use Pod::Dynamic' and builds some pod sections (or defines some variables) by running up to some point when $Pod::Dynamic::pod_mode is true. This means that 'dynperldoc' can simply do() the file and have some variables defined for use in generating the fully-formed pod. So, if the variables are changed to some other defaults, both 'dynperldoc script' and 'script --help' show the same values without having to manually regenerate anything. I've done similary on several occasions and it is fairly trivial. If you have trouble, I can probably dig up an example. I may take you up on that. CPAN's results for 'dynamic pod' are depressing. Thanks, Eric -- Left to themselves, things tend to go from bad to worse. --Murphy's Corollary