#!/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
In reply to Re: Count non unique groups of elements in an array
by Anonymous Monk
in thread Count non unique groups of elements in an array
by Sandy_Bio_Perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |