#!/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
In reply to Re: How to reorder a text file
by tybalt89
in thread How to reorder a text file
by hennesse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |