prob. with BEGIN/END 
Author Message
 prob. with BEGIN/END

Hello,

if I run gawk with
gawk -f test.awk test.awk
(the latter's just 4 this example) gwak outputs the word test followed
by linenumbers and nr. of fields - but no 'dies' or dashes before or
behind the whole thing. Did I misunderstand the BEGIN{} and END{} thing?
I did play around with the curly braces already...

tia,
bye,
Patrick

following is test.awk:

begin{
       printf "dies\n"
     }
{ printf("test %d %d\n",NR,NF) }
end{
    print NR "---"
   }

--


Fax: +49-821-804-3652



Sun, 21 Nov 1999 03:00:00 GMT  
 prob. with BEGIN/END

Quote:

>Hello,

>if I run gawk with
>gawk -f test.awk test.awk
>(the latter's just 4 this example) gwak outputs the word test followed
>by linenumbers and nr. of fields - but no 'dies' or dashes before or
>behind the whole thing. Did I misunderstand the BEGIN{} and END{} thing?

No, probably not. You just shouldn't assume that BEGIN{} and begin{} means
the same thing. As it stands, begin is just an unitialized variable like
any other, which means the pattern never succeeds. Use uppercase BEGIN and
all will be fine...

Quote:
>I did play around with the curly braces already...

>tia,
>bye,
>Patrick

>following is test.awk:

>begin{
>       printf "dies\n"
>     }
>{ printf("test %d %d\n",NR,NF) }
>end{
>    print NR "---"
>   }

--

============================================================================
Gert Durieux

Departement Germaanse Taal- en Letterkunde
Universiteitsplein 1 - A 1.27                   Phone   + 32 3 820 27 66
B-2610 Wilrijk                                  Fax     + 32 3 820 27 61
============================================================================



Sun, 21 Nov 1999 03:00:00 GMT  
 prob. with BEGIN/END

Quote:

> Did I misunderstand the BEGIN{} and END{} thing?
> following is test.awk:
> begin{printf "dies\n"}
> { printf("test %d %d\n",NR,NF) }
> end{print NR "---"}

It really is a "BEGIN" and "END" thing,
not a "begin" and "end" thing.


Sun, 21 Nov 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Cals Begin and End Balance

2. Smalltalk on the small end (was: Advice requested: GUI project beginning)

3. /BEGIN/ .. /END/ file reading

4. How to write filesearch with begin-pattern till end-pattern

5. begin/end doesn't behave as expected

6. Braces and begin/end

7. Suggestion for addition to Begin/End syntax

8. Are begin/end blocks atomic?

9. Beginning of End of Ada Mandate

10. remove begin and end tags and its content in between

11. Is Perlish BEGIN / END possible?

12. (start..end) where start > end

 

 
Powered by phpBB® Forum Software