Question on Split usage in Perl
        Posted  
        
            by 
                Nano HE
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Nano HE
        
        
        
        Published on 2010-12-24T07:21:22Z
        Indexed on 
            2010/12/24
            7:54 UTC
        
        
        Read the original article
        Hit count: 262
        
Hello.
I wrote an small script to use Split() as this,
use strict;
use warnings;
use Data::Dumper;
my $fh = \*DATA; 
while(my $line = <$fh>) 
{ 
    my @values = split(':', $line);
    foreach my $val (@values) {
      print "$val\n";
    }
} 
__DATA__   
1 : Hello World String10 : NO : A1B2,B3
11 : Hello World String11 : YES : A11B2,B3,B14,B25
A1B2,B3 and A11B2,B3 are characters form like Only One Letter A and One or Two Number 2, 3, 14,25 etc then concatenated with Only One Letter B and one or two Numbers like 2, 3, 14,25. etc
Now out put as this
1
 Hello World String10
 NO
 A1B2,B3
11
 Hello World String11
 YES
 A11B2,B3,B14,B25
How can I hold the last array member from @values and made concatenation and out put as this. 
1
 Hello World String1
 NO
 A1B2,A1B3
11
 Hello World String11
 YES
 A11B2,A11B3,A11B14,A11B25
Appreciated for your comments and replies.
[update]
My out put need the concatenation followed the rule.
A and one or two numbers and joined by B and one or two numbers split by ,
© Stack Overflow or respective owner