#!/usr/bin/env perl use strict; use warnings; my $txt = " Title 1 Line of text A Line of text B Title 2 Line of text C Title 3 Title 4 Line of text D "; my @reverse; my @normal = split /(Title \d)/, $txt; foreach my $n (0 .. @normal){ if ($n%2){ push @reverse, $normal[$n].$normal[$n+1]; } } chomp @reverse; @reverse = reverse @reverse; map { print $_."\n" } @reverse;
In reply to Re: How to reorder a text file
by monsenhor
in thread How to reorder a text file
by hennesse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |