in reply to Count non unique groups of elements in an array
#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1169780 use strict; use warnings; my @allele = <DATA>; my @newcounts; $_ = join '', @allele; push @newcounts, $& =~ tr/\n// while /^(.*\n)\1*/gm; print for @newcounts; __DATA__ HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*03:01 HLA-A*03:01 HLA-A*03:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:01 HLA-A*02:03 HLA-A*02:03 HLA-A*02:03 HLA-A*02:03 HLA-A*02:03 HLA-A*02:03 HLA-A*02:03 HLA-A*02:03
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Count non unique groups of elements in an array
by Sandy_Bio_Perl (Beadle) on Aug 15, 2016 at 07:33 UTC |