I am attempting to sort records within Perl. The record contains the field of the port of a Cisco switch which is[snip]
described as below in table A:
Table A -------------
Provided the records are coming to you in order, you can:
my %lines; foreach my $line (<DATA>){ chomp; $line =~m/^\s+(\d\/\d+)\s+(.*)$/; my $k = $1; push(@sorter, $k); my $v = $2; $lines{$1} = $2; } map{print $_, ' ',$lines{$_},"\n"[EMAIL PROTECTED];
__DATA__
3/1 spare notconnect 8 full 100 10/100BaseTX False disabled
3/2 spare disabled 6 full 100 10/100BaseTX False disabled
3/3 disabled 99 full 100 10/100BaseTX False disabled
3/4 disabled 99 full 100 10/100BaseTX False disabled
3/5 disabled 99 full 100 10/100BaseTX False disabled
3/6 disabled 99 full 100 10/100BaseTX False disabled
3/7 disabled 99 full 100 10/100BaseTX False disabled
3/8 disabled 99 full 100 10/100BaseTX False disabled
3/9 disabled 99 full 100 10/100BaseTX False disabled
3/10 disabled 99 full 100 10/100BaseTX False disabled
3/11 disabled 99 full 100 10/100BaseTX False disabled
3/12 disabled 99 full 100 10/100BaseTX False disabled
__END__
I'm sure you can adapt this concept to whatever you're actually netting.
If it isn't coming in order, then, I think you can split, sprintf the #'s and join -- then the sort may work as expected. Of course, the initial strings would have some extra zeros... which you could lose after sorting if you need to, I'd suppose. Just a stab in the dark here. I hope it helps.
-- Mike Higgins
^ ^ <-|-> (.)__ the world is a big box of paints. __ __ and others, the canvas we're dealt. | | - XTC _/ \_
_______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs