Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How to build a better mousetrap (or a variable to hold a column-measuring scale)

by LanX (Archbishop)
on Sep 09, 2019 at 23:13 UTC ( #11105917=note: print w/replies, xml ) Need Help??


in reply to How to build a better mousetrap (or a variable to hold a column-measuring scale)

more ways to do it, more generic :)
DB<111> $p = '|----+----' DB<112> p map { $a=$p; substr $a,0,length($_),$_ ;$a} "", map {$b=$_ +%10; $b ? $b*10 :$_*10 } 1..22 |----+----10---+----20---+----30---+----40---+----50---+----60---+---- +70---+----80---+----90---+----100--+----10---+----20---+----30---+--- +-40---+----50---+----60---+----70---+----80---+----90---+----200--+-- +--10---+----20---+---- DB<113> p map { $a=$p; substr $a,0,length($_),$_ ;$a} "",map $_*10, +map {1..9, $_*10} 1..2 |----+----10---+----20---+----30---+----40---+----50---+----60---+---- +70---+----80---+----90---+----100--+----10---+----20---+----30---+--- +-40---+----50---+----60---+----70---+----80---+----90---+----200--+-- +-- DB<121> p map { $a=length; $p =~ s/.{$a}/$_/r} "", map {$b=$_%10; $b + ? $b*10 :$_*10 } 1..22 |----+----10---+----20---+----30---+----40---+----50---+----60---+---- +70---+----80---+----90---+----100--+----10---+----20---+----30---+--- +-40---+----50---+----60---+----70---+----80---+----90---+----200--+-- +--10---+----20---+----

update

the initial pattern is buggy, replacing $p = '|---+----' would fix it.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2020-01-24 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?