foreach my $ix ( reverse 0 .. $#text ) { if ( not length $text[ $ix ] ) { splice @text, $ix, 1; splice @links, $ix, 1; } } #### for ( my $ix = $#text; $ix >= 0; -- $ix ) { # same loop contents. }