for my $i ($i=1; $i<=243; $i++) { print FH "$FORM{'item' . $i}\t$FORM{'qty' . $i}\n" if $FORM{'qty' . $i}; }