From: Fergal Daly (fergal at domain esatclear.ie)
Date: Wed 17 Oct 2001 - 12:47:46 IST
I'm sure this exact piece of Perl has been written thousands of times by a
other people but I wrote it today and I think it's lovely
perl -pe 's/.*?(\d+)(.*)/"$2 ".("*" x $1)/ge'
will draw a histogram. It takes lines of the form
123 thing
and produces lines of the form
thing **********
where there are 123 *s
Got a list of usernames that have logged in over the last week?
sort list | uniq -c | perl -pe 's/.*?(\d+)(.*)/"$2 ".("*" x $1)/ge'
will graph them.
I had a bunch of account numbers generated by some unknown algorithm and I
wanted to know would it be good idea to to use the last 2 characters as a
hash. So I grabbed out the last two chars of each one and luckily enough
sort last_two | uniq -c | cut -f 1 | sort | uniq -c | perl -pe 's/.*?(\d+)(.*)/"$2 ".("*" x $1)/ge'
gave me a nice tight bell curve.
I love Perl :-)
Fergal
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:12:47 GMT