Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: sorting /etc/hosts (boo)

by kjherron (Pilgrim)
on Aug 31, 2001 at 22:51 UTC ( [id://109492]=note: print w/replies, xml ) Need Help??


in reply to Re: sorting /etc/hosts (boo)
in thread sorting /etc/hosts

Your example sorts lexically, not numerically. It'll sort 10.10.10.10 before 10.10.10.2, for example:
my @lines=<DATA>; print sort @lines; __DATA__ 10.194.196.9 made-up 10.194.196.55 heckyll 10.194.196.57 txwl013w 10.194.196.61 krios 10.194.196.62 stasis # dial up server
This sorts the "made-up" line to the end, whereas the original poster presumably would want it first.

Like the other replies said, a numerical sort is more appropriate here. The number of "cycles" used either way is going to be pretty trivial.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://109492]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found