Hi All
I am very much in need of help splitting strings based on length in Perl. e.g.,
Input text is :
International NOUN
Corp. NOUN
's POS
Tulsa NOUN
Output I want is :
International I In Int Inte l al nal onal NOUN
Corp. C Co Cor Corp . p. rp. orp. NOUN
's ' 's __nil__ __nil__ s 's __nil__ __nil__ POS
Tulsa T Tu Tul Tuls a sa lsa ulsa NOUN
Please help me. Thanks in advance.
while(<DATA>){
my @tmp=split;
for(my $i=1;$i<=4;$i++){
$arr[$i]=substr($tmp[0],0,$i);
$arr[$i+4]=substr($tmp[0],-$i);
}
print $tmp[0]," ";
print join " ", @arr;
print " ",$tmp[1],"\n";
}
__DATA__
International NOUN
Corp. NOUN
's POS
Tulsa NOUN
Thanks for the reply. However, when I run it , it has gone to INFINITE loop. Also, please help me on how to read the input from a FILE and write the output into a FILE of the same format.
---------- Post updated 07-14-09 at 01:11 AM ---------- Previous update was 07-13-09 at 05:26 AM ----------
Thanks. It's working fine. I need help to modify above script for strings in utf8 format.