$pad = ' ' x 80; ## make the length the same as your max expected $c = "test test test"; $fmt = "A4 x1 A4 x1 A4 x1 A4"; @c = unpack($fmt, "$c$pad"); print join ("*",@c), "\n"; $d = "test test test "; $fmt = "A4 x1 A4 x1 A4 x1 A4"; @d = unpack($fmt, "$d$pad"); print join ("*",@d), "\n";