Syntactic Confectionery Delight | |
PerlMonks |
Re: A little golf anyone?by petral (Curate) |
on Oct 31, 2002 at 00:00 UTC ( [id://209285]=note: print w/replies, xml ) | Need Help?? |
Kinda silly at 143: but it does produce: from your sample (note truncation instead of rounding). Maybe I can think of something more sensible in the morning. upday:   Ok, this is simpler (102 chars): It still preserves numeric alignment with the original text, eg, and rounding adds 22 (to 124 chars): Update, the second: Here's a funny format one at 79 chars: which produces this: And an extendible one at 114 chars (got to be ready for those terrabyte-sized disks): Which does: Ok, here's a real one at 117 chars that does 1024-type m's and g's and t's: Which gets: This ignores several problems:  1) Before 5.6, perl expanded `qw(...)' into `split" ",'...'' (so you couldn't [index]it );  2) There's no protection against filenames or whatever which end with a string of 4 digits;  and 3) There's no provision for catching a number at the end of the line. Adding these back in, yields 132 chars:
(BTW, what comes after Terrabytes?) Update the last:   Updated the above to save a few strokes (and round properly on the 1024 one (changed %d -> %.0f)).   p
In Section
Meditations
|
|