in reply to Why is this split not doing anythine?

As Rolf said, you want to print the entire array, not just the blank line at the beginning. Better yet, remove blank lines and also perhaps the extra blank after the keyword?

use strict; use warnings; my $string="TOPO_DOM 1; /note=Cytoplasmic; /evidence=ECO:0000269|PubMe +d:24744376; TOPO_DOM 25..74; /note=Extracellular; /evidence=ECO:00002 +69|PubMed:24744376; TOPO_DOM 100..115; /note=Cytoplasmic; /evidence=E +CO:0000269|PubMed:24744376; TOPO_DOM 141..159; /note=Extracellular; / +evidence=ECO:0000269|PubMed:24744376; TOPO_DOM 183..227; /note=Cytopl +asmic; /evidence=ECO:0000269|PubMed:24744376"; my @split_topodom = split(/TOPO_DOM\s*/, $string); @split_topodom = grep {/\S/}@split_topodom; # remove blank lines print join "\n",@split_topodom; __END__ 1; /note=Cytoplasmic; /evidence=ECO:0000269|PubMed:24744376; 25..74; /note=Extracellular; /evidence=ECO:0000269|PubMed:24744376; 100..115; /note=Cytoplasmic; /evidence=ECO:0000269|PubMed:24744376; 141..159; /note=Extracellular; /evidence=ECO:0000269|PubMed:24744376; 183..227; /note=Cytoplasmic; /evidence=ECO:0000269|PubMed:24744376
Update: Of course you can combine the grep that removes blank lines into the split line.
my @split_topodom = grep{/\S/}split(/TOPO_DOM\s*/, $string);

Replies are listed 'Best First'.
Re^2: Why is this split not doing anythine?
by Anonymous Monk on Feb 22, 2023 at 21:52 UTC
    Oh wow, I did not notice THAT!! I feel so stupid now :P Thank you both!