sub my_increment { my $value = $_[0]; my @positions = reverse split //, $value; my $chk_carry = 1; $positions[0]++; if(@positions == 1) {return;} foreach my $iter (0 .. $#positions) { if( ($positions[$iter] eq '0') && $chk_carry) { $positions[$iter+1]++; # Note that this may lengthen the # number. It's either allowing # that or checking and throwing an # overflow. } else{$chk_carry = 0;} } $_[0] = join '', reverse @positions; }