in reply to How to reorder a text file

#!/usr/bin/perl # https://perlmonks.org/?node_id=1216436 use strict; use warnings; print reverse split /^(?=Title)/m, do{ local $/; <DATA>}; __DATA__ Title 1 Line of text A Line of text B Title 2 Line of text C Title 3 Title 4 Line of text D

Outputs:

Title 4 Line of text D Title 3 Title 2 Line of text C Title 1 Line of text A Line of text B

Which I think is more valid than your Desired Output

Replies are listed 'Best First'.
Re^2: How to reorder a text file
by hennesse (Beadle) on Jun 11, 2018 at 23:20 UTC
    Works perfectly - Thank you!