use Text::ParseWords 'shellwords'; open my $infh , '<' , 'print_tools.txt' or die "... $!"; while( <$infh> ){ my $printer = ( shellwords($_) )[0]; print qq{modelCombo.addItem("$printer")\n}; } close $infh;