#!/usr/bin/perl use strict;
use warnings;
my @file = <DATA>;
chomp(@file);
remove_empty_sentences(\@file);
print "$_\n" for @file;
sub remove_empty_sentences {
my $array_ref = shift;
my @offsets;
for(my $i = 0; $i <= $#{ $array_ref }; $i++ ) {
if( $array_ref->[$i] eq '<s>'
and $array_ref->[$i + 1] eq '</s>' )
{
splice(@{$array_ref}, $i, 2);
}
}
}
__DATA__
<s>
hallo
ich
bin
müde
</s>
<s>
das
ist
ein
satz
</s>
<s>
</s>