my $file = 'blah.html'; # Slurp the file contents into one big string open my $fh, '<', $file or die "Cannot open $file: $!"; my $str = do { local $/; <$fh>; }; close $fh; # Split on '>' my @results = split '>', $str; print "Check :", $#results, "\n";