The stupid question is the question not asked PerlMonks

### Comment on

 Need Help??

Let me implement the other algorithm too. This one is longer, but you could cut some of it if you reorganized it so that there's only one function doing the work of all three.

```use 5.010;
{
no warnings "uninitialized";
my(\$a, \$b) = @_; my @b = @\$b; my \$c;
for (my \$k = 0; @b || \$c; \$k++) {
\$c = 10 <= (\$\$a[\$k] += \$c + shift @b); \$\$a[\$k] %= 10;
}
}
sub dsub {
my(\$a, \$b) = @_; my @b = @\$b; my \$c;
for (my \$k = 0; \$k < @\$a; \$k++) {
\$c = (\$\$a[\$k] -= \$c + shift @b) < 0; \$\$a[\$k] += 10 * \$
+c;
}
\$c;
}
sub dcmp {
my(\$a, \$b) = @_; my @a = @\$a; my @b = @\$b; my \$r;
while (@a || @b) {
if (my \$t = shift @a <=> shift @b) { \$r = \$t; }
}
\$r;
}
}
my \$n = [reverse split //, "4335043554366887798866555766"];
my \$p = [1];
my \$e = 0;
while (0 <= dcmp(\$n, \$p)) {
dadd \$p, \$p for 0..3; \$e++;
}
my \$r;
for my \$_e (0 .. \$e - 1) {
my \$i = 0;
while (0 <= dcmp (\$n, \$p)) {
dsub \$n, \$p; \$i++;
}
\$r .= sprintf "%x", \$i;
}
say \$r;
__END__

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
 marioroy I tried to find the culprit module with unsafe DESTROY or END block, but too many dependencies and gave up.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2017-08-24 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Who is your favorite scientist and why?

Results (363 votes). Check out past polls.

Notices?