#!/usr/bin/perl -w use strict; open HTML, "temp.html" or die "Can't open file: $!\n"; { local $/; $_ = ; } close HTML; tr/\n / /s; while ( /([^<>]*)(<[^>]*>)?/g ) { print "TEXT: $text\n" if defined $1; print "HTML: $html\n" if $2; }