use strict; my $str = "1234"; my $ss = pack "A2", $str; print "'$ss'\n"; ### example shows example of padding blanks $ss = pack "A5", $str; print "'$ss'\n";