Help with some codes

heya all!

well, am such a newbies in this world of ruby language, though! i found
it very interesting language and i am pretty much can catch up myself
but not as fast as i’ve thought. anyway, below are some source code
which i need some alternation to make it loop and adding ‘while’
statement…anybody could have something to say??

regards

Do you mean mac_conf.each_with_index { |mac, aplist|…?

Ingrid paris wrote:

heya all!

well, am such a newbies in this world of ruby language, though! i found
it very interesting language and i am pretty much can catch up myself
but not as fast as i’ve thought. anyway, below are some source code
which i need some alternation to make it loop and adding ‘while’
statement…anybody could have something to say??

regards

I think your problem line should be changed to

macaddr.each { |mac, aplist| puts “\n ALERT!\t\n An Imitation of MAC
address
#{mac} were found >> #{aplist.inspect}” if aplist.size > 1}

(Note in particular that you iterate over the hash ‘macaddr’, not the
closed IO object mac_conf, and since aplist is an array you need to
check aplist.size)