in reply to Re^8: Saving sql results to an array all rows?
in thread Saving sql results to an array all rows?
Seeing as how you are sorting ip adresses, you could simplify this sort routine using Socket's function inet_aton.
Socket is included with perl 5.8.8 at least, and likely for earlier versions of perl.#!/usr/bin/perl use strict; use warnings; use Socket; use Data::Dumper; my @data = map{[split]} <DATA>; 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: Saving sql results to an array all rows?
by learningperl01 (Beadle) on Aug 21, 2008 at 15:21 UTC | |
by Cristoforo (Curate) on Aug 21, 2008 at 16:10 UTC | |
by learningperl01 (Beadle) on Aug 21, 2008 at 17:33 UTC | |
by learningperl01 (Beadle) on Aug 21, 2008 at 17:52 UTC |