No hardcoded numbers at all. Call it with prog.pl <length>:#!/usr/bin/perl use strict; use warnings; my $len = $ARGV[0]; my $cur = 10; print "|---+----"; while ($cur < $len) { my $prn = $cur % 100 ? $cur % 100 : $cur; my $sep = substr "|----+----", length($prn); print $prn, $sep; $cur += 10; } print "|\n";
~/tmp$ perl ruler.pl 50 |---+----10---+----20---+----30---+----40---+----| ~/tmp$ perl ruler.pl 140 |---+----10---+----20---+----30---+----40---+----50---+----60---+----70---+----80---+----90---+----100--+----10---+----20---+----30---+----|
In reply to Re: How to build a better mousetrap (or a variable to hold a column-measuring scale)
by Paladin
in thread How to build a better mousetrap (or a variable to hold a column-measuring scale)
by roho
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |