http://qs321.pair.com?node_id=1216446


in reply to How to reorder a text file

Taken from Re: Split and print hash based on regex
#!/usr/bin/perl use strict; use warnings; open my $fh, '<', \<<EOF; Title 1 Line of text A Line of text B Title 2 Line of text C Title 3 Title 4 Line of text D EOF { local $/; print reverse <$fh> =~ /(^Title(?:(?!^Title).)*)/msg; }