On 3/29/2008 3:12 PM, mjc wrote:
> On Mar 27, 8:05 pm, stan <smo...@[EMAIL PROTECTED]
> wrote:
>
>>Ed Morton wrote:
>>
>>
>>>On 3/27/2008 11:48 AM, Boltar wrote:
>>>
>>>>On Mar 27, 4:36 pm, Ed Morton <mor...@[EMAIL PROTECTED]
> wrote:
>>>
>>>>>On 3/27/2008 11:27 AM, Boltar wrote:
>>>>
>><snip>
>>
>>>>but I guess that just another one of awks irritating little quirks.
>>>
>>>It is not an awk quirk, it's one of the many getline features that
aren't
>>>intuitively obvious and all of which need to be thoroughly understood
before
>>>deciding whether or not to use getline.
>>
>>Personally, I found that I needed a firm fixed rule that every time I
>>type getline I have to get up and go get a cup of coffee. Without any
>>exceptions that I can remember I always find that I was trying to write
>>a c progrm in awk and with a little reflection I can find a solution
>>that uses awk instead of fighting against it.
>
>
> I'm the reverse - I LIKE getline.
>
> I have a utility subroutine for checking if a file exists:
>
> function exists(file , line)
> {
> if ( (getline line < file) > 0 )
> {
> close(file);
> return 1;
> }
> else
> {
> return 0;
> }
> }
>
> I tend to use gawk as a general purpose programming language, so the
> fact that it is C-like is a plus to me.
Deciding to explicitly write
while read line {
split line into field1 field2 field3....
}
when that's already provided by the tool by default doesn't make that tool
any
more general purpose or C-like.
> When the pattern-matching paradigm is appropriate, I use it; when it
> isn't, I use getline to read from any number of files.
I don't see the inverse relationship between pattern-matching and
explicitly
reading input.
> imho, the contortions needed to not use getline when reading multiple
> files are less clear than using getline for all but one.
What contortions? Could you give a small example of the problem?
> Please don't vote me off the island.
getline has it's uses, see http://tinyurl.com/yn9ka9
for a list.
Ed.


|