It's a bit ugly, but here is one way to do it :

#!/usr/bin/perl
my @array = ('1900-0', '1900-1', 'NULL', 'NULL', '1900-2', '1900-4', '1902-5', '1902-6', '1902-7', '1902-8');
my $num1900 = 'EARFCN=1900, PCID=';
my $num1902 = 'EARFCN=1902, PCID=';
for (@array) {
    # print $_ . "\n";
    $num1900 .= (split '-', $_)[1] . '&'
        if $_ =~ /1900/;
    $num1902 .= (split '-', $_)[1] . '&'
        if $_ =~ /1902/;
}
$num1900 =~ s/\&$/;/;
$num1902 =~ s/\&$/;/;
print $num1900 . "\n";
print $num1902;

Cheers !
---
Vincent Lequertier
s...@riseup.net

Le 2015-05-06 09:19, Anirban Adhikary a écrit :
Hi List
I have the following array ---
('1900-0','1900-1','NULL','NULL','1900-2','1900-4','1902-5','1902-6','1902-7','1902-8');
There are two part for each element separated by a dash.
first one known as earfcn and second one is pcid .
The requirement is For the same “earfcn”, concatenate the “pcid” values
using "&" separator between values.
so the output will be like this
EARFCN=1900,PCID=0&1&2&4;
EARFCN=1902,PCID=5&6&7&8;

I am not able to generate any idea how to adress this isuue. Please give me
some starting point.

Best Regards
Anirban.

--
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