my @BuildToke=(); while ( my $token = $stream->get_token ) { if (( $token->is_comment and $token->as_is eq '') .. ($token->is_comment and $token->as_is eq '')){ $newcontent = $token->as_is; #if $token->is_text; push @BuildToke,$newcontent; } } open FH, ">", $file or die "Error opening for overwrite $file: $!\n"; print FH @BuildToke; close FH; } } exit(0);