foreach my $ix ( reverse 0 .. $#text ) { if ( not length $text[ $ix ] ) { splice @text, $ix, 1; splice @links, $ix, 1; } }