in reply to Search and replace text

Thanks everyone. I have another related question. Is it possible to randomly generate char within a certain range? For example if i want to generate two random chars between "aa" and "ff" so that the output will be like
ab ad df ca . . .
PS. this is not a homework assignment. I finished college long ago. I just learn new tools to help me do my job and Perl is the mother of all tools.

Replies are listed 'Best First'.
Re^2: Search and replace text
by BrowserUk (Patriarch) on Jan 27, 2006 at 04:23 UTC

    Here are a couple of ways:

    print join'',map{ chr 97+rand(6) } 1 .. 2 for 1 .. 100; ## Slightly wasteful, but you only do it once ## and reuse the array each time. my @pairs = grep{ /[a-f]{2}/ }'aa' .. 'ff'; print $pairs[ rand @pairs ];

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.