in reply to file reading issues

I have comments in the file and want to grab the stuff between them.
I would consider using HTML::TokeParser. I use the following.

#!/bin/perl5 use strict; use warnings; use HTML::TokeParser; my $file = 'index.html'; my $tp = HTML::TokeParser->new($file) or die "Couldn't parse $file: $!"; my ($start, $html); while (my $tag = $tp->get_token) { if ( $tag->[0] eq 'C' and $tag->[1] eq '<!-- article start -->' ) { $start++; next; } next unless $start; if ( $tag->[0] eq 'C' and $tag->[1] eq '<!-- article end -->' ) { last; } $html .= $tag->[4] if $tag->[0] eq 'S'; $html .= $tag->[1] if $tag->[0] eq 'T' or $tag->[0] eq 'C'; $html .= $tag->[2] if $tag->[0] eq 'E'; } print "$html\n"; # ["S", $tag, $attr, $attrseq, $text] # ["E", $tag, $text] # ["T", $text, $is_data] # ["C", $text] # ["D", $text] # ["PI", $token0, $text]