use strict; open FILE, ") { chomp; if (/^<.*>$/) { push @tags, $_; } else { push @text, $_; } } print "Tags:\n", join "\n", @tags; print "\nText:\n", join "\n", @text;