Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to generate random sequence of UTF-8 characters

by johngg (Abbot)
on Dec 20, 2012 at 19:56 UTC ( #1009787=note: print w/ replies, xml ) Need Help??


in reply to How to generate random sequence of UTF-8 characters

it would be trivially simple

But very long-winded! Perhaps using Range Operators and map would save some typing?

$ perl -Mstrict -Mwarnings -E ' > my @chars = q{0} .. q{9}; > push @chars, map { $_ => uc } q{a} .. q{z}; > say for @chars;' 0 1 2 3 4 5 6 7 8 9 a A b B c C ... y Y z Z $

This does not address your problem but I hope it is of interest.

Cheers,

JohnGG


Comment on Re: How to generate random sequence of UTF-8 characters
Download Code
Re^2: How to generate random sequence of UTF-8 characters
by Lotus1 (Chaplain) on Dec 20, 2012 at 20:28 UTC

    Here's another way:

    my @chars = ( 0..9,'a'..'z','A'..'Z' ); print @chars; __DATA__ 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

    update: And one more:

    my $string = join '',0..9,'a'..'z'; $string =~ s/([a-z])/$1\u$1/g; print $string; __DATA__ 0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ

      Thanks lotus and JohnGG. Both solutions are quite interesting.

      Thanks

      Ted

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009787]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-07-02 04:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (27 votes), past polls