learingperl01
MIS
Hello everyone I was hoping someone could please point me in the right direction with the problem I am having/trying to solve. I currently have an array which gets populated with data as shown below which has date time ips ports etc, similar info you would find in a log file.
2008-08-01 10.10.10.1 12373 2.2.2.2 80 hxxp://2.2.2.2 200 OK
2008-07-26 10.168.1.1 11122 3.3.3.3 80 hxxp://3.3.3.3 200 OK
Now what I am trying to do is sort/order by the source IP address which in this case would be 10.10.10.1 and 10.168.1.1 In the past I have used
the following to sort and array of IP's but not sure how to go about it when there are other fields in the array.
How would I got about sorting this data based on the IP address. FYI the IP address is always at the same location in the logs.
thanks for the help in advance.
2008-08-01 10.10.10.1 12373 2.2.2.2 80 hxxp://2.2.2.2 200 OK
2008-07-26 10.168.1.1 11122 3.3.3.3 80 hxxp://3.3.3.3 200 OK
Now what I am trying to do is sort/order by the source IP address which in this case would be 10.10.10.1 and 10.168.1.1 In the past I have used
the following to sort and array of IP's but not sure how to go about it when there are other fields in the array.
Code:
@ip (this would be a list of IP addresses);
use Sort::Key::IPv4 qw(ipv4sort);
my @sorted = ipv4sort @ip;
How would I got about sorting this data based on the IP address. FYI the IP address is always at the same location in the logs.
thanks for the help in advance.