From: Ruby Student Date: 2013-06-22T01:16:39+09:00 Subject: A question about assignment of multidimensional array error message --089e0115f91c242dd304dfac63c0 Content-Type: text/plain; charset=ISO-8859-1 Team, The piece of code below is giving me an error which I can't find the solution. The assignment below for * msgCount[r][c] = mtc *is trwoing an exception. which I list below. Any suggestions? ################################################################### #Date READ ENTRY DELETE ALARM HOTLIST SITE # #20130611 2000000 200000 200000 2000 2000 20000 # #20130611 2000000 200000 200000 2000 2000 20000 # ################################################################### msgCount = Array.new # Empty array. Will have size of [r][7]. Rows will grow fn = "/home/rb/MyData/dp/PR_LOGS/pr_time.log.*" msgTypes = ["read", "entry", "delete", "alarm", "hotlist", "site"] fnls = `ls #{fn}`.split # Create fnls = file names list fc = fnls.size # Number of files to be processed fnls.each do |f| # Process each file r = 0 # Rows are controlled by fnls, number of files lp,lg,dt = f.split('.') # this info will be used later 7.times do |c| # Process each column mtc = `grep #{msgTypes[c]} #{f} | wc -l` # Get Message Type Count *msgCount[r][c] = mtc* r += 1 # Next row please end end *in `block (2 levels) in
': undefined method `[]=' for nil:NilClass (NoMethodError)* Thank you -- Ruby Student --089e0115f91c242dd304dfac63c0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Team,

The piece of code below is gi= ving me an error which I can't find the solution. The assignment below = for
msgCount[r][c] =3D mtc
is trwoing an exception. which I list= below.

Any suggestions?

#####################= ##############################################
#Date=A0=A0=A0=A0=A0 READ= =A0=A0=A0=A0 ENTRY=A0=A0=A0 DELETE=A0=A0=A0 ALARM=A0=A0 HOTLIST=A0=A0 SITE= =A0=A0=A0=A0 #
#20130611=A0 2000000=A0 200000=A0=A0 200000=A0=A0=A0 2000= =A0=A0=A0 2000=A0=A0=A0=A0=A0 20000=A0=A0=A0 #
#20130611=A0 2000000=A0 200000=A0=A0 200000=A0=A0=A0 2000=A0=A0=A0 2000=A0= =A0=A0=A0=A0 20000=A0=A0=A0 #
##########################################= #########################

msgCount =3D Array.new=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 # Empty array. Will have size of [r][7]. Rows will grow

fn=A0=A0 =3D "/home/rb/MyData/dp/PR_LOGS/pr_time.log.*"
msgTypes =3D ["read", "entry", "delete", &q= uot;alarm", "hotlist", "site"]

fnls =3D `ls= #{fn}`.split=A0=A0=A0=A0=A0=A0=A0=A0 # Create fnls =3D file names list
fc =3D fnls.size=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # Numbe= r of files to be processed

fnls.each do |f|=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 # Process each file
=A0=A0 r =3D 0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # Rows are controlle= d by fnls, number of files
=A0=A0 lp,lg,dt =3D f.split('.')=A0= =A0=A0=A0=A0 # this info will be used later

=A0=A0 7.times do |c|=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # Proce= ss each column
=A0=A0=A0=A0=A0 mtc =3D `grep #{msgTypes[c]} #{f} | wc -l= `=A0 # Get Message Type Count
=A0=A0=A0=A0=A0 msgCount[r][c] =3D mtc<= /b>
=A0=A0=A0=A0=A0 r +=3D 1=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 # Next row please
=A0=A0 end
end


in `block (2 levels) in <main>': = undefined method `[]=3D' for nil:NilClass (NoMethodError)

Thank you
--
Ruby Student
--089e0115f91c242dd304dfac63c0--