Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: ASCII Rulers

by Tyke (Pilgrim)
on Apr 03, 2001 at 17:02 UTC ( #69286=note: print w/ replies, xml ) Need Help??


in reply to ASCII Rulers

This is another approach that might not be shorter, but does work with ruler lengths that aren't a multiple of 10. Update: Just noticed that petral does it more neatly.

#!perl -w use strict; print ruler(@ARGV); sub ruler { my ($x,$y) = (' ', ''); map{$x.=sprintf('%10d',$_/10) if $_%10 == 0 && $_ != 0; $y.=$_%10} ( +0..$_[0]); return "$x\n$y\n"; }
I would have liked to use for rather than map, but I couldn't get the 1 line version to compile ;-(

I also can't get it to work with non-positive integer values ;-((.


Comment on Re: ASCII Rulers
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://69286]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-07-28 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls