[EMAIL PROTECTED] wrote:
I am reading in a file, building an array of information that I need
to evaluate:
while (<FILE>) {
if ($_ =~ m/stuff/) {
push(@data, {'vlan' => $vlan, 'host' => $host, 'mac' => $mac, 'port'
=> $port});
}
}
Small sample of @data:
vlan host mac port
13 switch-1 111427f2ffff gi1/1/49
13 switch-1 111511614fff gi1/1/49
13 switch-1 11155e45ffff gi1/1/49
13 switch-1 1115fc4753ff gi1/1/49
111 switch-1 11196f977f72 gi1/1/49
111 switch-1 11196fff3728 gi1/1/49
111 switch-1 11196fe74f5f gi1/1/49
111 switch-1 111f56f1fcef gi1/1/1
111 switch-1 111f6123f789 gi1/1/2
111 switch-1 111f6124336f gi1/1/2
111 switch-1 111f61245f94 gi1/1/5
111 switch-1 111f6147eeff gi1/1/2
111 switch-1 111f61896fff gi1/1/2
I would like to sort the array based on the value of $data[$i]
{'port'}.
my @sorted = sort { $a->{ port } cmp $b->{ port } } @data;
I have a feeling that I am going about this in the wrong
way. Can I use hashes in a better way to sort the data based on the
keys? Better yet, can I evaluate the number of keys that match each
other?
I don't understand what that means.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/