Rudif has asked for the wisdom of the Perl Monks concerning the following question:
I need to generate simple sequences of $n characters, for any positive $n (within reason), starting at 'a' and wrapping back to 'a' after 'z'.
The first code line in my loop, below, generates the sequence that I need.
Question 1: Other / better / faste ways of generating this sequence, anyone?
Question 2: Why does my second code line generate something entirely different?
Rudiffor my $n (25..28) { printf"%s\n",pack"C*",map{$_%26+ord'a'}0..$n-1; # ok printf"%s\n",pack"C*",map{ord'a'+$_%26}0..$n-1; # not ok } __END__ abcdefghijklmnopqrstuvwxy 0123456789111111111122222 abcdefghijklmnopqrstuvwxyz 01234567891111111111222222 abcdefghijklmnopqrstuvwxyza 012345678911111111112222220 abcdefghijklmnopqrstuvwxyzab 0123456789111111111122222201
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: generating a character sequence
by I0 (Priest) on Aug 22, 2001 at 06:15 UTC | |
by Hofmator (Curate) on Aug 22, 2001 at 15:01 UTC | |
|
Re: generating a character sequence
by little (Curate) on Aug 22, 2001 at 03:04 UTC | |
|
Re: generating a character sequence
by runrig (Abbot) on Aug 22, 2001 at 03:05 UTC | |
|
Re: generating a character sequence
by George_Sherston (Vicar) on Aug 22, 2001 at 03:23 UTC |