John W. Krahn wrote:
> Papapep wrote:
>> 
>> How should I do to split a long string that the only thing I know is
>> that is a multiple of a previous defined number (for example 26).
>> 
>> A graphic example:
>>
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx
yzabcdefghijklmnopqrstuvwxyz
>> 
>> That's four times 26 (104) but I don't (I can't) count every string
>> because they are really long (They can be of thousands of
>> charachters). 
>> 
>> So what I should do, I think, is a loop that get the first 26
>> charachters and print them in a new file, after that evaluates if
>> there is more string to get, and so on, but I am not able to see how
>> it works... :-/ 
>> 
>> Give me some advice, please (the command I should use, or group of
>> commands, etc...)
> 

        You might look at sysopen, sysread which  allows you to read in max
blocks of data and process that data.

        It would look something like:

    sysopen(FILEIN,$filein,0) || die "unable to open file $filein: $!";
    bindmode(FILEIN);
    my $rcdbuf  =   "";
    my $rcdcnt  =   0;
    my $rcdmax  =   26;
    my $rcdcntrtn = 0;
    my @MyWorka = ();
    while ( 1 ) {
        sysseek(FILEIN,$rcdmax*$rcdcnt,0);
        $rcdcntrtn = sysread(FILEIN,$rcdbuf,$rcdmax);
        if  ( defined $rcdcntrtn ) {
            @MyWorka = unpack("a26",$rcdbuf);
            $rcdcnt++;
              # could write your new file out here or do what you want.
            # if there can be less an x multiples, then you might need to
check the length
         }else {
                last ;
           }
     } # end of while

    close(FILEIN);

A different approach. ps If there can be linefeeds or carriage returns, then
you will have to approach it different also.

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to