On Sat, 13 Apr 2002 02:12:44 +0100, p kent wrote: >with the Mac toolbox stuff. Anyway, attached is Getopt::Mac, with POD, and >a little demo program. I don't pretend that this code is particularly >pretty and I'm sure it can be made a lot cleaner. However, it does work on >my machine :-)
I finally got the chance to check it out. What can I say: waugh. This really is neat. The main problem I'm having is a bunch of "use of uninitialized value" warnings, on the line my $oktext = ($pageN<$ofPages) ? 'Next...' : 'OK'; in the sub "go". The reason is that $pageN and $ofPages are undef if you have just a single dialog page. While I'm poking around... the whole $pageN, $ofPages thing is fishy. I think your calculation says that you need 4 pages if you allow 8 items per page and you have 24 items. You need my $ofPages = int((@args-1)/$maxPerDialog+1); Also, there's too much repetition in the code to my taste: there's no need to separate the final page from the rest. splice() works fine with fewer items than you want to splice off. my $pageN; while ( @args > $maxPerDialog ) { my @subargs = splice @args, 0, $maxPerDialog; my %result = go(++$pageN, $ofPages, @subargs); keys %result or return 1; foreach( keys %result ) { $MASTEROPTIONS{ $_ } = $result{ $_ }; } } go() should then check if $ofPages is larger than 1, not check if $pageN is false, because it won't be. -- Bart.