Skip to content

Instantly share code, notes, and snippets.

Created December 4, 2014 02:19
Show Gist options
  • Save anonymous/dec27b7eca8b568a1965 to your computer and use it in GitHub Desktop.
Save anonymous/dec27b7eca8b568a1965 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(1)
in_file = File.new(ARGV[0], 'r')
in_file.each_line do |line|
ip_string = ipString(line)
ip_hash = ip_hash['ip_string' => 1]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment