Thread elemente filtern? (21 answers)
Opened by miki280 at 2005-12-07 13:55

esskar
 2005-12-07 14:09
#60755 #60755
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
nehmen wir an, du hast die datei schon in ein array eingelesen...

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use strict;
use warnings;

my @lines = (
'3 | 1853 1239 293 293 293 293 293 293 292',
'5 | 1853 1239 293 293 293 293 293 293 3428'
);

foreach my $line ( @lines ) {
  my ( $id, $path ) = split /\s+\|\s+/, $line, 2;
 
  $path = join ' ', unique( split / /, $path );
  print "$id | $path\n";
}

sub unique {
   my %h = ();
   return grep { !$h{$_}++ } @_;
}
\n\n

<!--EDIT|esskar|1133957430-->

View full thread elemente filtern?