Hi All,
Been wondering if this is doable in AWK for some time but always worked around it in the past.
Below I initialize an array with 3 months of the year... for readability I ommited the other 9 months. These months are then used in the if-statement as part of a regular expression, but AWK doesn't like it. I can't seem to find anything in the awk/gawk manuals regarding this kind of semantic... am I really stuck with restating the same code 12 times? Also is it possible to use arr[i] in the loop as a substring of a variable name? I wrote pseudo-code below to give an idea of what I'm trying to accomplish. I know it's doable in SNOBOL ;-) Thanks!
BEGIN {
arr[0] = "AUG"
arr[1] = "SEP"
arr[2] = "OCT"
}
{
for(i in arr)
{
if($1 ~ /arr[i]/)
{
#Controls flows into here if $1 matches AUG, SEP, OCT
#Furthermore, pretend I want to intialize a variable like AUGseen:
arr[i]seen = 1
}
}
}
If either of these things are doable I greatly appreciate pointers!