
while ( $seq = <STDIN> )
{
    chomp $seq;
    $pos = index( $seq, "GATATC", 0 );

    print "\n\nSequence : $seq\n";
    if ( $pos < 0 )
        { print "No cutting site for EcoRV located.\n"; }

    print "Fragment lengths (in bp) are : \n";

    $previous_pos = $pos;
    while( $pos >= 0 )
    {
        if ( $previous_pos == $pos ) 
            { printf "==> %6d\n", $pos+3; }
        else
            { printf "==> %6d\n", $pos - $previous_pos; }

        $previous_pos = $pos;
        $pos = index( $seq, "GATATC", $previous_pos+1 );
    }

    if ( $previous_pos < 0 )
        { printf "==> %6d\n", length( $seq ); }
    else
        { printf "==> %6d\n", length( $seq ) - $previous_pos - 3; }
}
