in reply to Problem of Duplicating an Array while Parsing Text

You want to push an AoA:

elsif ( $line =~ /^$/xms ) { push @temp2, [(@temp,[@ins_grp])] if (@ins_grp); @ins_grp = (); }

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Problem of Duplicating an Array while Parsing Text
by monkfan (Curate) on Dec 20, 2005 at 08:15 UTC
    Thanks GrandFather, but it produce this instead: Which is still not quite right.

    Regards,
    Edward

      You have an extra level introduced in the push @all and you need to flush @temp2:

      elsif ( $line =~ /\^+/xms ) { push @all, @temp2; @temp2 = (); }

      With both sets of changes applied to your original code it now prints:

      $VAR1 = { 'mus09r' => [ [ 'AGAGAAAG 1', '7', '0.142138988325903', '3', '0', [ '7.66666666666667', '1,-424,CAGAGACAGGGGAGAGATAG', '1,-338,AAGAGAAAGGGAGGAGAGGC', '1,-349,AAGAGGGGAGGAAGAGAAAG' ] ], [ 'AGAGAAAG 1', '7', '0.142138988325903', '3', '0', [ '7.66666666666667', '1,-337,AGAGAAAGGGAGGAGAGGCA', '1,-348,AGAGGGGAGGAAGAGAAAGG', '1,-423,AGAGACAGGGGAGAGATAGA' ] ], [ 'AGAAACAG 1', '7', '1.36112386682747', '4', '4', [ '7.66666666666667', '1,-383,TGAGAAACAG', '1,-319,CAAGAAACAG', '0,-457,CTTGAAACAG' ] ] ] };

      DWIM is Perl's answer to Gödel
      I think your desired input doesn't match your desired output. Recheck your inputs, because you seem to have got them switched. Good luck.