how to get rid of spaces in the output from this perl script

I have a perl script that actually parses following sample file:
gene            1995..3119
     CDS             1995..3119
                     /note="identified by match to protein family HMM PF00712;
                     match to protein family HMM PF02767; match to protein
                     family HMM PF02768; match to protein family HMM TIGR00663"
                     /product="DNA polymerase III, beta subunit"
gene            5318..5872
     CDS             5318..5872
                     /note="identified by match to protein family HMM PF05258"
                     /product="putative protein of unknown function (DUF721)"

Here is the script:
use strict;
use vars
$table_line ='';

                my $product =$1;
                while (<>)
                        last unless /^\s+\/product=(.*)/;
                        $product =$product.$1;

                $table_line =$table_line.$product."\t";
                $table_line = $table_line.$1."\t";

                my $translation = $1;
                while (<>)
                        last unless /^\s+\        (.*)/;

                print "$table_line\n";
                $table_line ="";


Here is the output from the script:  This script parses the input file and puts required entries in tabbed format in a output file:

"DNA polymerase III, beta subunit"      "tigr:AAur_0002"

"putative protein of unknown function (DUF721)" "tigr:AAur_0005"

I wanted this script to inseatd not to print the blank spaces , instead it shd just print the required output in tabbed format .. any clues how can i get rid  of these blank spaces ..
Who is Participating?
ozoConnect With a Mentor Commented:
       print "$table_line\n" if $table_line;
Before printing, try:

$table_line =~ s/^\s*$//g;
bjuneja_2000Author Commented:
hmm ,
Actually I tried that before , it didn't work .., not sure why ..
Any other clue ?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.