Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Math::Base - arithmetics with baseX integers (updated)by shmem (Chancellor) |
on Aug 22, 2017 at 12:19 UTC ( [id://1197795]=CUFP: print w/replies, xml ) | Need Help?? |
Another "Silly use for Perl" entry. Anonymous Monk asked for a method for incrementing mixed letters and numbers recently, which particular need is satisfied with Math::Base36. Can we do better? I guess, yes.
Far from complete, but fun enough yet. For me, that is... ;-) Update: Below is an updated version which handles negative numbers, implements missing operators and lets you define your own charset for baseX conversion, e.g. to calculate base3 with qw(a b c). Also, a method integer() is added which emulates use integer globally for all calculations, and some utility methods/functions. Update: fixed some bugs I'll eventually make it into a CPAN package proper.
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Back to
Cool Uses for Perl
|
|