🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #99

gawk anomaly?

#99
From: Don Stewart
Date: Mon, 06 Apr 1992 05:55
26 lines
1508 bytes
In the following, the line 'print "class:"$0' prints nothing as the code now stands.
HOwever, by uncommenting 'print class[$2]', the above DOES print.
What am i doing wrong? (fails even in this stripped eg)
---------------------------------
/depot/gnu/bin/gawk ' 
 FILENAME == "rt.crse" {      # fmt of crse data: crse#[.A-H]section{\t}instructor
	      course[$1]=$2   # eg. 103.001	smith
	    }                 #     497B001	wesson
 FILENAME == "SHIELDS.data" {                    # student registration data
		      if(substr($0,52,1) != " ") # data has space if no course letter
		        crse = substr($0,49,7)   # eg. convert '103 001' -> '103.001'
		      else                         
		        crse = substr($0,49,3)"."substr($0,53,3) 
		      if (crse in course) {
			class[substr($0,22,9)] = class[substr($0,22,9)] ":" crse  
		         		#'22,9' is ssn
		      }
       }
 FILENAME == "masterssn" {
	OFS = ":"
#       print class[$2]  #bad side effect: this creates entry for $2 w/ null value
    if ($2 in class) {
     print "class:"$0
    }
 }
' FS="	" rt.crse FS=":" masterssn SHIELDS.data
Technical Details
Message-ID: <92Apr6.095510edt.37072@colossus.cs.psu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.psu.edu!stewart

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.psu.edu!stewart
From: stewart@cs.psu.edu (Don Stewart)
Subject: gawk anomaly?
Message-ID: <92Apr6.095510edt.37072@colossus.cs.psu.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 6 Apr 1992 05:55:02 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 27