in reply to ASCII Rulers
A couple of minor golfish things, without really changing the algorithm:
p
But for filling exactly to (arg) columns (eg, to avoid wrapping when using $ENV{COLUMNS}):sub ruler { my $n = 9 + shift; chop $n; join "", " ", map(" "x(9-/../).$_, 1..$n), "\n", "0123456789" x $n, "0\n" }
update: or (of course) ye olde one-liner:perl -lwe 'print" ",map(" "x(9-/../).$_,1..$ARGV[0]/10),"\n",map/.$/g,0..shift' further update: chipmunk got it.  He's almost using printf as a map!sub ruler { my $n = shift; join"", " ", map(" "x(9-/../).$_, 1..$n/10), "\n", map(/.$/g, 0..$n), "\n" }
p
|
---|
In Section
Cool Uses for Perl