Posted by: Anonymous Coward
on January 17, 2006 12:17 PM
Your example illustrates one of the `problems' with awk.
Because awk by design runs its entire program on every input line (more exactly, each record) separately, it can get `awk-ward' when you are trying to communicate information between input lines.
This is especially true when the `entity' you are interested in spans multiple input records. In these situations you are often faced with horrible warts where you need to initialise stuff in a BEGIN block, tidy up the last entity in the END block, use flags (like `change' in your example) to track state, and also be you need to be very very careful when planning the order that your blocks take, and the interaction between those blocks.
People who use ordinary structured procedural languages are used to initialising, tidying up and tracking state, but for me the beauty and power of awk is that most of the time NONE of that is neccessary. One-liners are 90% of what I would use awk for so I feel really uncomfortable when that one line suddenly bloats out with all this other stuff.
I am not saying that there is a better way for awk to handle this sort of situation, and nor am I saying that any other language handles it with more ease. Certainly I don't believe any language that handles it better than awk can compete with the simple awk one-liner. I just think that there is a point at which awk is easier, and another point at which it suddenly ceases to be easier.
Re:Get a list of your interface addresses
Posted by: Anonymous Coward on January 17, 2006 12:17 PMBecause awk by design runs its entire program on every input line (more exactly, each record) separately, it can get `awk-ward' when you are trying to communicate information between input lines.
This is especially true when the `entity' you are interested in spans multiple input records. In these situations you are often faced with horrible warts where you need to initialise stuff in a BEGIN block, tidy up the last entity in the END block, use flags (like `change' in your example) to track state, and also be you need to be very very careful when planning the order that your blocks take, and the interaction between those blocks.
People who use ordinary structured procedural languages are used to initialising, tidying up and tracking state, but for me the beauty and power of awk is that most of the time NONE of that is neccessary. One-liners are 90% of what I would use awk for so I feel really uncomfortable when that one line suddenly bloats out with all this other stuff.
I am not saying that there is a better way for awk to handle this sort of situation, and nor am I saying that any other language handles it with more ease. Certainly I don't believe any language that handles it better than awk can compete with the simple awk one-liner. I just think that there is a point at which awk is easier, and another point at which it suddenly ceases to be easier.
#