Thread Array "zusammenziehen" (undef Stellen löschen) (11 answers)
Opened by fulug at 2006-05-28 03:51

bloonix
 2006-05-29 16:36
#66651 #66651
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Wenn das Array ein paar MBs groß ist, könnte man das eventuell noch
etwas schonender für den Speicher lösen.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
use strict;
use warnings;
use Data::Dumper;

my @old = ( 2, 5, 13, undef, 6, 8, undef, 3);
my @new;

while (@old) {
  my $val = shift @old;
  push @new, $val if defined $val;
}

print Dumper(\@new);


Gruß,
opi\n\n

<!--EDIT|opi|1148906301-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.

View full thread Array "zusammenziehen" (undef Stellen löschen)