Created
December 4, 2014 02:19
-
-
Save anonymous/dec27b7eca8b568a1965 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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