we can do many ways so here is to sort based on numeric
sort is by default based on strings but if you want to sort based on number in perl
syntax:sort{$a <=>$b}
Code:
@ipaddress = ('172.27.32.200','10.1.1.60','192.20.30.133','172. 19.32.100');
@ips=sort{$a<=>$b}(@ipaddress);
foreach (@ips)
{
print "$_\n";
}
Leave a comment: