in reply to The best way to split tab delimited file

Perfect opportunity for a negative lookbehind.

my @vareach=split(/(?<!,)\t/,$var);

Replies are listed 'Best First'.
Re^2: The best way to split tab delimited file
by Ratna_Ranjan (Novice) on Nov 23, 2009 at 17:30 UTC
    Below is the data,where the regex is not working..
    my $var='474627 asidase ta sidase ala,"lpha-D- ctoside gtohydrolase +","razyme","arazyme (enz Corp)","Melie","lagal","idase bta", + rug 00103';

      There are no tab characters in that line. Presumably due to a cut/paste issue. Can you try again to get the tabs in there? And also show the output you expect vs the output you are getting?

        my $var='474627 asidase ta sidase ala,"lpha-D- ctoside gtohydrolase +","razyme","arazyme (enz Corp)","Melie","lagal","idase bta", ru +g 00103'; my @each=split(/(?<!,)\t/,$var); for my $eachvar(@each) { print "$eachvar\n"; }

        This is the output i get

        474627 asidase ta sidase ala,"lpha-D- ctoside gtohydrolase","razyme","arazyme (enz Corp)","Melie","lagal","idase bta", rug 00103

        This is the output i expect

        474627 asidase ta sidase ala,"lpha-D- ctoside gtohydrolase","razyme","arazyme (enz Co +rp)","Melie","lagal","idase bta", rug 00103