use strict; use warnings; my $data = do {local $/; }; $data =~ y/ \n/ /s; # add the following if you want to strip space after > # and before < characters. # $data =~ s/(?<=>)\s|\s(?=<)//gm; print "$data\n"; __DATA__ condition condition randomness other junk more junk