On Mon, Jun 16, 2008 at 11:52 PM, Dermot <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have data in a tab delimited format like this (tabs might be lost in
> the formatting of the email).
>
> A456/959        ScHe
> M920/1123      He
> D123/999        ChFl
> D123/949        AnFl
> S520/257        Sp
> T510/106         TePeHe
> T540/110         Te
> T875/1010       TeSc
> T875/1050       TeSc
>
>
> I need to split the 2nd column. The string is to be split into 2
> characters , so ChFl becomes 'Ch, Fl' . I can't seem to find a RE that
> will split the data correctly.

I think RE can do it.
Try this:

use strict;

while(<DATA>) {
    chomp;
    my $str = (split)[1];
    my @characters = $str =~ /\w{2}/g;
    print "@characters","\n";
}

-- 
Jeff Peng - [EMAIL PROTECTED]
Professional Squid supports in China
http://www.ChinaSquid.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to