- or download this
use List::Util qw( reduce );
...
my ( $str ) = @_;
reduce { mul2( $a, $b ) } "", split //, $str;
}
- or download this
sub mul2 {
my ( $str, $have_overflow ) = @_;
...
( $have_overflow ? 1 : '' ) . $ret;
}
- or download this
sub mul2 {
my ( $str, $have_overflow ) = @_;
...
( $c % 10 ) or ( length() ? 0 : '' );
} reverse '', split //, $str;
}