#!/usr/bin/perl use strict; use warnings; use Socket; use Data::Dumper; my @data = map{[split]} ; print Dumper \@data; my @sorted = map{$_->[0]} sort {$a->[1] cmp $b->[1]} map { [$_, inet_aton($_->[1]) ]} @data; print Dumper \@sorted; __DATA__ alpha 2.23.14.71 beta 10.23.14.71 gamma 25.26.1.6 delta 1.2.3.4 epsilon 10.24.14.71