Forum: Ruby Help with some codes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4ef5efc30e79631752e742f66eeb533e?d=identicon&s=25 Ingrid paris (strawb3rry7ady)
on 2008-10-12 12:46
Attachment: alert3.txt (579 Bytes)
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
20228e1a65c9717555f80030a6e8779f?d=identicon&s=25 Rüdiger Brahns (Guest)
on 2008-10-12 13:30
(Received via mailing list)
Do you mean mac_conf.each_with_index { |mac, aplist|...?
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2008-10-12 21:32
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)
This topic is locked and can not be replied to.