hello -
i am trying to take a text file with multiple sets of numbered lines and sort each set, leaving the non-numbered text in place. i can't seem to figure out how to loop over the regular text, save then sort the numbered text, then move on. i want to take a file like this:
test
001
003
002
004
test
020
022
024
023
and make a file like this:
test
001
002
003
004
test
020
022
023
024
so far only have this for sorting individual number blocks:
$datafile = "/Users/path/file";
open(DAT, $datafile);
@dataarray = <DAT>;
@grep = grep(/^\d/, @dataarray);
@sort = sort @grep;
print @sort;
but i can't seem to incorporate this into a full script (and i know there's a more succinct way to write that...it's just the best i could do and have work). is there an easy way to do this that i'm missing? or do i have to write a complicated match? i'd love anyone's input on this - i've tried snooping around but haven't found this problem. thank you in advace!