inc@tc.fluke.COM (Gary Benson) (02/21/91)
I have two questions and one answer to pose to the group: I read this group regularly, but I may have missed the discussions of my questions on two items so please bear with me if my problems have been solved long ago... -=[ QUESTION ONE ]=- I have been writing a lot of tools lately, and Perl is the first language I have ever actually studied, having no formal programming training. I have had great success, though, and I think that is a credit to its designer -- that even a neophyte like myself can become productive with minimal pain and with a sharp upslope on the learning curve. Anyway, my tools are text filters and preprocessors, with a spattering of database management thingies. They form a package of sorts, and lately I have been thinking it would be really terrific to combine them into one Sun tool. I looked at some example applications, but they seem to be all written in C...I suppose I could start (for the 3rd time) trying to learn C, but I don't really have the time for that (what a typically Perlish thing to say!) Does anyone have examples of tools, walking menus, or a full Sun application written in Perl? Even the lower level stuff like "Panel" and "Click Button" would be helpful. -=[ QUESTION TWO ]=- A few days ago, perldb.el was posted here, and THANK YOU, THANK YOU, THANK YOU! It took off and flew hassle-free and I love it. The debugger in one window and the program in another presents a programming environment that is just lovely. I pop between the windows, scan around, tweak this or that to see the effect, and in general feel that these two running together make a good match. NOW! There MUST be an emacs major mode for Perl, right? I'm sure I've seen discussion of it, but can someone point me to any files I need to get it going? Is it a standard part of GNU Emacs 18.52.30? If so, how do I turn it on? What'll it do? -=[ AN ANSWER ]=- I'd like to contribute a fragment showing how we solved the Initial Capital Letters problem that has been discussed here recently. We use it to properly capitalize headings, figure titles and table captions, but also to ensure that articles, prepositions and a few other short words that can appear in them are not capitalized. # INITCAPS, a subroutine to convert strings to initial capitals # Inputs 1 argument, a string. Returns the string in initial caps except # words in $specials are translated by look up. sub initcaps { local($out,$in,$word,$lw,$found); $in = $_[0]; $out=''; while (length($in) > 0) { $in =~ s/^( *)([^ ]*)//; $out .= $1; # transfer the white space before words $word = $2; # setup the next word ($lw=$word) =~ tr/A-Z/a-z/; # make a lowercase version $found = $specials{$lw}; # on the always special list? if ($found && $out !~ /^ *$/) { # exception word but not first in line $word = $found; # exception words as specified. } elsif ($word =~ /^[a-z]*$/i){ # word is only alphabetics? $word =~ tr/a-z/A-Z/; # make an uppercase version $word = substr($word,0,1) . substr($lw,1,999); # combine lowercase version } $out .= $word; } $out; } # SPECIALS LOOKUP TABLE # These words are translated by lookup. The left string must be # lower case. The the right string is the desired replacement, and # can be any case, or even a different word if you need that. $specials{"a"} = "a"; $specials{"an"} = "an"; $specials{"and"} = "and"; $specials{"as"} = "as"; $specials{"ascii"} = "ASCII"; $specials{"at"} = "at"; $specials{"but"} = "but"; $specials{"by"} = "by"; $specials{"for"} = "for"; $specials{"from"} = "from"; $specials{"in"} = "in"; $specials{"is"} = "is"; $specials{"it"} = "it"; $specials{"nor"} = "nor"; $specials{"of"} = "of"; $specials{"on"} = "on"; $specials{"onto"} = "onto"; $specials{"or"} = "or"; $specials{"out"} = "out"; $specials{"perl"} = "Camel Filters. They Satisfy!"; $specials{"so"} = "so"; $specials{"to"} = "to"; $specials{"the"} = "the"; $specials{"with"} = "with"; $specials{"yet"} = "yet"; -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ -- Gary Benson -=[ S M I L E R ]=- -_-_-_-inc@fluke.com_-_-_-_-_-_-_-_-_-_- Life is an onion, you peel it a year at a time and sometimes you cry. -Carl Sandburg