The problem doesn't seem to be the -w, but rather that $In_Mente is forgotten. -w is always complaining about uninitialized-whatsoever, so we'll just have to make some precautions:

sub add($$) { my ($Val1, $Val2) = @_; my ($Result, $Tmp) = ('',0); my $In_Mente = ''; (length($Val1) < length($Val2)) ? ($Val1, $Val2)=($Val2, $Val1):0; while (length($Val2) || length($Val1)) { $Tmp = substr($Val1,-1,1); $Tmp += substr($Val2, -1, 1) if (length($Val2)); $Tmp += $In_Mente if (length($In_Mente)); if ($Tmp > 9) { $In_Mente = 1; $Tmp -= 10;} else { $In_Mente = ''; } $Result = $Tmp . $Result; substr($Val1, -1, 1) = ''; substr($Val2, -1, 1) = ''; my $FResult = $Result; last if ($In_Mente eq '' && !length($Val2)); } $Result = $In_Mente . $Result; $Result = $Val1 . $Result; return $Result; } $a = '99999999999999999999999999999999999999999999'; $b = '1'; print " $a\n+ $b\n= ", add($a, $b);

Prints out:
99999999999999999999999999999999999999999999 + 1 = 100000000000000000000000000000000000000000000

In reply to Re: Re: oldschool math by PerpLexicon
in thread oldschool math by Anonymous Monk

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.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.