Hi guys....
1. I am trying to form a sequence with letter DA of width 100..
2. I want to restrict the occurrence of 'DA' in this 100(characters) to 20%, 30% and so on...
i.e
DADADDDADDD
There are 3 DA's in the string...
I want to have control on occurrence of DA and generate sequence randomly for 100 characters
#!/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 ;
But i am not able to have control on the occurrence of 'DA'
It keeps changing randomly with this coding
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.