<?xml version="1.0" encoding="Windows-1252"?>
<node id="647554" title="Finding a pattern in a string" created="2007-10-27 03:35:48" updated="2007-10-26 23:35:48">
<type id="115">
perlquestion</type>
<author id="647552">
Kenin</author>
<data>
<field name="doctext">
Hi guys....
&lt;p&gt;

1. I am trying to form a sequence with letter DA of width 100..
&lt;p&gt;
2. I want to restrict the occurrence of 'DA' in this 100(characters) to 20%, 30% and so on... 
&lt;p&gt;
i.e
&lt;c&gt;
DADADDDADDD
&lt;/c&gt;
There are 3 DA's in the string...
&lt;p&gt;
I want to have control on occurrence of DA and generate sequence randomly for 100 characters

&lt;c&gt;
#!/usr/local/bin/perl
my @chars = ('A','D',);
my $string = join '', map $chars[ rand @chars ], 1 .. 100;
    while ($string =~ /DA/g) { $count++ }
    print "There are $count DA's in the string \n ";
print $string ;
&lt;/c&gt;

But i am not able to have control on the occurrence of 'DA'
&lt;p&gt;
It keeps changing randomly with this coding
</field>
</data>
</node>
