in reply to Align string on a 32-bit boundary with padding

There are so many ways to do this. Here's one:

use strict; use warnings; use Test::More tests => 1; my $have = '6578616d706c652e6d65'; my $want = '6578616d706c652e6d650000'; my $mult = 8; my $padchar = '0'; my $padlen = length ($have) % $mult; $have .= $padchar x ($mult - $padlen) if $padlen; is $have, $want;

See also the FAQ.

without use any external module?

You mean like String::Pad for instance? Why not use the best and most extensive archive of modules on the net?


🦛