Hi Anamika

I know this thread has focussed on using split -- thought I'd add a
regex powered version for reference/comparison.

cheers

Matthew


use strict;
use warnings;

while (<DATA>) {
        my @keys;

        @keys = $_ =~ m/(NM_\d+)+/g;

        $_ =~ m/\:1\s+(.*)$/;

        print "$_ = $1\n" foreach (@keys);
}


__DATA__

NM_009648,NM_001042541:1        0.955794504181601
NM_019584:1     0.900900900900901
NM_198862:1     0.835755813953488
NM_001039093,NM_001039092,NM_153080:1   0.805008944543828




On 4 April 2012 22:57, Anamika K <anamika...@gmail.com> wrote:
> Hello All,
> I have a file like this:
>
>
> NM_009648,NM_001042541:1        0.955794504181601
> NM_019584:1     0.900900900900901
> NM_198862:1     0.835755813953488
> NM_001039093,NM_001039092,NM_153080:1   0.805008944543828
>
> and want output like this:
>
> NM_009648  0.955794504181601
> NM_001042541:1  0.955794504181601
> NM_019584:1     0.900900900900901
> NM_198862:1     0.835755813953488
> NM_001039093  0.805008944543828
> NM_001039092   0.805008944543828
> NM_153080:1  0.805008944543828
>

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to