#!/usr/bin/perl use strict; use warnings; open (IFH, "data.txt"); while (my $code = ) { chomp($code); # $code = "0.104567556ORIG.MAXWELL."; my $str1 = "foo"; my $str2 = "bar"; print sprintf("%32s %7s %s\n", "$code", $str1, $str2); } close IFH; #### __DATA 0.104567556ORIG.MAXWELL. #### $ ./test.pl foo bar56ORIG.MAXWELL. $ ./test.pl 0.104567556ORIG.MAXWELL. foo bar