#!/usr/bin/perl use warnings; use strict; use Socket qw( inet_aton inet_ntoa); # takes file paths as argument for (@ARGV) { local $, = $/; open my $fh, '<', $_ or die $!; print map { inet_ntoa($_) } sort { $a <=> $b } map { chomp; inet_aton($_) } <$fh>; print $/; close $fh or die $!; }