undef $/; my $read = 'test.html'; open (FILE, "<$read") or die ("Couldn't open file to read: $!"); my $file = ; close FILE; my @possible_search_terms = split /]*?>/i, $file; foreach (@possible_search_terms) { next if $_ =~ /^\s*$/; print "WORKING: '" . $_ . "'\n"; }