Ralph Shumaker wrote: > Barry Gershenfeld wrote: >>> ...I want to be selective about which sigs are selected... >>> I thought about making a script that...greps certain lines >>> >> >from the main sig file... >> >>> But my problem is that I need grep to cough up everything between the >>> two "%" delimiters, not just the matching line.... >>> >> >> Learn awk, maybe? >> >> As your ideas become fancier, the programming effort you need also >> increases. This is the natural succession of things. While it may be >> possible to do it all with a shell script, more advanced programs can >> make >> it easier, more repeatable, and more modifiable. I see you've gotten sed >> into the act, and that's the kind of next step I'm talking about. >> >> When I climbed onto the Linux bandwagon, I figured I needed to progress >> through 3 levels. I see there are really 4. >> >> shell script >> sed >> awk >> perl >> >> And the reality was: >> >> I didn't realize shell scripts even counted as a language. But >> growing up >> with DOS Batch would make you think that. Shell scripts are good, and >> sometimes, a script is enough. Often, there's a script behind the final >> product anyway. >> > > I don't know if I consider scripts (or batch) files to be a "language", > but they *are* a set of instructions, hence a program, especially if > branching occurs. > >> sed was easy enough, but every time I went to use it, it would break >> down as >> soon as I needed to handle things that took more than one line. sed can >> work across line endings, but it ain't pretty. >> >> awk is like a real programming language. It has the guilty pleasures >> associated with string handling, and easy (or no?) data typing, and of >> course with regular expressions thrown in. awk solves most of my >> problems >> that are like the one you propose. >> >> perl, I never got to. I did read a "get started" article once, to sort of >> look into it, but didn't have a pressing need for it. At the perl >> level, >> you have python and php and as it happened I've also learned php. >> >> So...awk is where I would go with this. And if you want to try it >> (have you >> done any "programming language"s?), I'll help, as I suspect the onlookers >> would, too. >> > > Well, most don't esteem BASIC very highly, but that was my first > language on a Radio Shack Pocket PC with a whopping 1.3K RAM. Then > BASIC on Apple II with an incredible 64K RAM which eventually was too > small to run the paint program I was creating (so had to move to the > Apple IIe with 128K RAM). > > I found out that goto was frowned upon, and so started avoiding it, > which really wasn't much of a problem after I got the hang of gosub. > > Years later, frustrated with the glitches in the work order program that > we were using at work, I peeked into the code, and was surprised how > similar FoxBase (pre-FoxPlus) database programming code was to BASIC. I > pretty much picked up FoxBase on the fly (by the seat of my pants). > After I made several improvements to the code, I was loaned a book on > FoxBase programming. I occasionally referred to it (which was usually > spot on), but usually just figured things out from the context and from > its similarity to BASIC. The original FoxBase code for the work order > program ended up ballooning up to 3 times the original size. And I'll > tell you, it was *much* easier to use, and more feature rich. > > Years later (several years ago), I dabbled in Perl, but didn't really > have a project that was driving me. Well, that's not exactly true. But > I kinda lost interest when I got waist deep in the mud when trying to do > something specific (namely, wanting the program to continue working > _until_ a keystroke was entered, temporarily jump into a subroutine to > process the keystroke, and then resume). I was told that I *might* be > able to accomplish what I wanted with things that employed :: in the > name. All in all, it went so far over my head so fast and not enough > help that I just finally lost interest. It is a project I *still* would > like to work on. And with this much passage of time, perl has no doubt > implemented a lot more into its code. I got a little excited when I > found out that perl no longer required a hash of hashes to get two > dimensional arrays (IIRC). > > I seem to recall that with Perl, I could slurp the entire sig file into > a single variable. And I'm sure that I probably have forgotten *some* > perl, but I imagine that even that which I have forgotten would probably > come back pretty quickly. > > I haven't messed with awk, not at all. > > I would like to learn more. I don't feel like I got to a functional > level with perl. But I suppose I actually was "functional", tho barely > that. I never got to a level where I could call outside modules (those > things with :: in the names). But I remember getting to a point where I > realized I could use global variables and local variables, which could > both help me with the project I wanted to do. > > I would love to become proficient in perl. I had a couple of books, one > very basic level (written for the total newb), and another that was > probably intermediate to advanced. I do not presently know the location > of those books except that they are somewhere in my possession.
I'm no perl-wizard but I have spent a few years writing perl code, and I would recommend something other than perl -- unless you already have a good reason to specifically use perl. Perl is famous for text handling, but other languages are nearly as good. Perl is famous for one-liners, but only after you get fairly proficient. There are certainly other pluses, but in each case, I find it hard to send beginners off chasing them. I would suggest python (my favorite) or maybe tcl. Hmmm, maybe lua? (Andy:?) ??? or maybe even pascal ??? ==> Hey Gus: does delphi fit in this context. I would also suggest skipping sed and awk (unless you want to see some of the ideas that led to perl). Both are good things for sysadmins to have in their toolbags, but I think for an ordinary mortal just doing occasional scripting, I would jump from shell to (say) python. Regards, ..jim -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
