# Help with some codes

**URL:** <https://www.ruby-forum.com/t/help-with-some-codes/150742>\
**Category:** Ruby\
**Created:** [October 12, 2008, 12:46pm UTC](https://www.ruby-forum.com/t/help-with-some-codes/150742 "2008-10-12T12:46:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![strawb3rry7ady](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@strawb3rry7ady](https://www.ruby-forum.com/u/strawb3rry7ady)\
**Post date:** [October 12, 2008, 12:46pm UTC](https://www.ruby-forum.com/t/help-with-some-codes/150742/1 "2008-10-12T12:46:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![strawb3rry7ady](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@strawb3rry7ady](https://www.ruby-forum.com/u/strawb3rry7ady)\
**Post date:** [October 12, 2008, 1:30pm UTC](https://www.ruby-forum.com/t/help-with-some-codes/150742/2 "2008-10-12T13:30:53Z")

</div>

Do you mean mac\_conf.each\_with\_index { |mac, aplist|…?

---

<div class="post-metadata">

**Author:** ![strawb3rry7ady](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@strawb3rry7ady](https://www.ruby-forum.com/u/strawb3rry7ady)\
**Post date:** [October 12, 2008, 9:32pm UTC](https://www.ruby-forum.com/t/help-with-some-codes/150742/3 "2008-10-12T21:32:13Z")

</div>

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)
