[PLUG] Perl sorting problem...

Michael C. Robinson plug_1 at robinson-west.com
Wed Aug 10 23:25:06 UTC 2011


On Wed, 2011-08-10 at 16:00 -0700, Randal L. Schwartz wrote:
> >>>>> "Michael" == Michael C Robinson <plug_1 at robinson-west.com> writes:
> 
> >> Show me what might be in $a and $b there, and what order you want them
> >> in.
> 
> Michael> I saw $a <=> $b described as magic on the web, I know nothing
> Michael> about it.
> 
> It's two elements of the list.
> 
> Michael> Binary format as in I went from a string to a binary number via:
> 
> Michael> Net::IP::ip_iptobin($ip_string,4);
> 
> Oh, those are simple.  They're already just a series of bits. Sort them
> string-wise:
> 
> my @sorted = sort @original_list;
> 
> Done. :)
Yes, awesome, done.

Okay, stage 1 completed.  For stage 2, I need to take an existing sorted
list of binary numbers, sort a new list of these numbers, and combine
the two in sorted order.  I think I'll use perl to maintain the IP list
and build a server to serve requests for these numbers from a C program.
First things first, how to sort into a preexisting sorted list new
numbers.  Can arrays be concatenated in perl?  If so, I'm thinking
concatenate the new list and the old one and do a sort on the result.





More information about the PLUG mailing list