Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Very impressive. Made me waste a lot of time trying to beat it!

I think I've got it just a little shorter. I don't know if the time I spent on this has brought me any closer to enlightenment, but it did make me fast (as in skip a meal)...
perl -e'%h=map{/.\s/;7**(ord$&&30)-$`,$_}`du -h`;die @h{sort %h}'
66 characters.

The key is the 7 to the power of ord(char) bitwise 30 part. I had to write a little perl script that would find the magic values 7 and 30 which would work for a lexicographic (default) sort. That is, I take 7 to the power of those values, and subtract the value of $` ... to produce hash keys which sort properly.

Then I take a hash slice on the sorted result. The sort actually returns the entire flattened hash sorted, keys and values, but since the values in that hash don't map to anything, they are silent.

I think I need to go get something to eat.

In reply to Re^6: du -h, sorted by bellaire
in thread du -h, sorted by bellaire

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 02:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found