On Sat, Jun 21, 2003 at 12:40 PM -0700, Ioana Cozmuta wrote: >>I do understand the problem, however I do not know how to put it in a perl >>script. For example, in C this could be solved using pointers. >>As I mentioned in my first e-mail, the data are tab delimited. If between >>the tabs there is no value, then I know that one value is missing and I >>also know at which position the value is missing because the pointer could >>tell me the exact position in the line. >> >I think the following code is closely what you need: >while (<INFILE>) { > chomp; > s/\t\t/\t0\t/g; # insert 0 > push @arr, [ split (/\t/, $_) ]; >} >
If there were more than two tabs in a row, the provided code needed adjustment. One solution is here: while (<INFILE>) { chomp; while ($_ =~ /\t\t/g) { s/\t\t/\t0\t/;} push @arr, [ split (/\t/, $_) ]; } Pavle