Skip to content

Instantly share code, notes, and snippets.

Created December 4, 2014 02:57
Show Gist options
  • Save anonymous/ff35732891c8608ce364 to your computer and use it in GitHub Desktop.
Save anonymous/ff35732891c8608ce364 to your computer and use it in GitHub Desktop.
def ipString(line)
match = line.scan(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
match.each do |x|
split_array = x.split(".")
return split_array.map{|str| str.rjust(3, '0') }.join '.'
end
end
unless ARGV.size == 1
puts "Invalid number of arguments?"
else
ip_hash = Hash.new(0)
in_file = File.new(ARGV[0], 'r')
in_file.each_line do |line|
ip_string = ipString(line)
if ip_hash.has_key?('ip_string') #if true
#ip_hash = ip_hash['ip_string']
else
#ip_hash = {'ip_string'}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment