lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (07/27/90)
We are approaching the point at which we need to make the final decisions on which examples to include in The Book. If you have any short, illustrative Perl scripts, or some favorite idiom that you think might be good to include, zing them off to either Randal or me ASAP. If you have some script that you published earlier but have since improved, feel free to send in a revised copy, especially if it got shorter. Best would be small things in the 5-50 line range, though we'll have a few longer examples. In particular, examples that stress the use of some particular feature are welcome. We can't guarantee to use everything you send, but we'll try our best to acknowledge our sources for the things we do use. We probably can't use anything copyrighted, unfortunately. Also welcome are any questions you feel the book should answer that the manual page doesn't (or doesn't answer very well). Even just ideas for words to put in the Glossary. We want to know where you get tripped up. Larry
marc@athena.mit.edu (07/27/90)
Will it be possible to see the book online before it is too late to make changes? I find it much easier to provide context diffs than nebulous suggestions. Also, here's a package I wrote which makes interactive perl scripts easier to write. Given an array of the form: @menu = ( "command1","perlsub1","help", "command2","perlsub2","help2", ); It goes into a loop prompting for commands and executing them. "exit" exits the loop, "quit" or ^D exits the program, and "help" displays help. --cut-- # package, meant to be do'ed, not run directly # # $Id: menu.pl,v 1.1 90/07/25 02:57:15 marc Exp $ # package menu; @gencmds = ( "help","__internal","Print the list of commands in this menu", "?","","help", "exit","__internal","Exit the current menu", "quit","__internal","Quit", ); sub main'menu { # @_ = ($prompt,@cmds) local($prompt,@cmds,%fcts,%helps); $prompt = shift(@_); @table = (@_,@gencmds); while (@table > $[) { $cmd = shift(@table); $fct = shift(@table); $help = shift(@table); if (defined($fcts{$cmd})) {next;} if ($fct eq "") { $fct = $fcts{$help}; $help = $helps{$help}; } push(@cmds,$cmd); $fcts{$cmd} = $fct; $helps{$cmd} = $help; } while (1) { print "\n$prompt: "; if (!($_ = <>)) { print "eof on input. Aborting...\n"; exit(2); } chop; if (defined($fct = $fcts{$_})) { if ($fct eq "__internal") { # Magic... if (($_ eq "help") || ($_ eq "?")) { foreach (@cmds) { printf "%-15s%s\n",$_,$helps{$_}; } } elsif ($_ eq "exit") { return; } elsif ($_ eq "quit") { exit(0); } else { die "Bogon __internal $_!\n"; } } else { if (index($fct,"'") == ($[-1)) { $fct = "main'".$fct; } eval("&$fct();"); } } else { print "\"$_\" is not a valid command. Type ? for help.\n"; } } } --cut-- One thing I've thought about adding is argument parsing. Maybe even an eval statement, so you can answer a prompt with perl code :-) Other ideas? Marc