Stan> I want to intelligently set up enscript (with a font size,
Stan> with portrait or landscape, and with -2 or not) depending on
Stan> how long the lines are. But I'm willing to accept some line
Stan> wraps, just not too many. What's the best way to get some
Stan> output like:
Stan> 0: 50
Stan> 1: 5
Stan> . . .
Stan> 46: 300
Stan> . . .
Stan> 80: 23
Stan> . . .
Stan> 110: 2
Stan> where the first number is the number of characters in the
Stan> line, and the second number is the number of lines in the
Stan> file with that line length?
Stan> How would you do this? In awk, perl, or any other tool?
#!/usr/bin/perl
$length{length}++ while <>;
print map "$_: $length{$_}\n",
sort { $a <=> $b } keys %length;
Or, in 1.5 lines:
perl -ne '$x{length}++;' \
-e 'END {print map "$_: $x{$_}\n", sort { $a <=> $b } keys %x; }'
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $18,720.69 collected, $172,159.85 spent; just 789 more days
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Web: <A HREF="http://www.teleport.com/~merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me