use strict; use warnings; use Data::Dumper; my @lines = ( '2008-07-26 13.168.1.1 11122 3.3.3.3 80 hxxp://3.3.3.3 200 OK' +, '2008-07-26 10.169.1.1 11122 3.3.3.3 80 hxxp://3.3.3.3 200 OK' +, '2008-07-26 10.168.2.1 11122 3.3.3.3 80 hxxp://3.3.3.3 200 OK' +, '2008-07-26 10.168.1.1 11122 3.3.3.3 80 hxxp://3.3.3.3 200 OK' +, ); my @sorted = map { $_->[0] } sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] || $a->[3] <=> $b->[3] || $a->[4] <=> $b->[4] } map { [$_, split(/\./, (split /\s+/, $_)[1] ) ] } @lines; my @all_rows = map { [ split( /\s+/, $_ ) ] } @lines; my @sorted1 = map { join( ' ', @{ $_->[0] } ) } sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] || $a->[3] <=> $b->[3] || $a->[4] <=> $b->[4] } map { [$_, split(/\./, $$_[1] ) ] } @all_rows; print Dumper( @sorted1 );
In reply to Re^3: Saving sql results to an array all rows?
by Krambambuli
in thread Saving sql results to an array all rows?
by learningperl01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |