Thread Präfixe aus Liste herausarbeiten
(11 answers)
Opened by Philipp at 2012-01-30 22:06
so würde ich es machen:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #!/usr/bin/perl use strict; use warnings; my @array=( 21112340, 21112341, 21112342, 21112343, 21112344, 21112345, 21112346, 21112347, 21112348, 21112349, 21112350, 21112351, ); my %test; for(@array) { $test{$1}+=2**$2 if($_=~/^(\d{7})(\d)/); } my @new_array; for my $val (@array) { my $v=substr($val,0,7); if($test{$v} && $test{$v}==(2**10)-1) { push(@new_array,$v) if(!@new_array or $new_array[-1]!=$v); } else { push(@new_array,$val) } } print "$_\n" for(@new_array); |