in reply to Unable to remove items from an array that are empty ' '
This is how you can fix it:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @left_split = ('stuff', '', 'stuff', '', '10', '', '-', ''); my $index = 0; while ($index <= $#left_split) { if ('' eq $left_split[$index]) { splice @left_split, $index, 1; } else { ++$index; } } print Dumper \@left_split;
But I would simply use grep:
@left_split = grep '' ne $_, @left_split;
|
|---|