Derek B. Smith am Donnerstag, 28. September 2006 22:28:
> > Why not just specify a non-digit for the first
> > character:
> >
> > my @a = ( 0 .. 9, 'a' .. 'z', 'A' .. 'Z');
> >
> > my $password = join '', $a[ 10 + rand( @a - 10 ) ],
> > map $a[ rand @a ], 1 .. 5;
> >
> >
> >
> > John
>
> Ok great, but I do not fully understand this. Will you
> explain in English?

Join with '':
a) a randomly selected entry from @a excluding the digits
   at positions 0..9 [the part between the 1st and 
   2nd comma]
b) five randomly selected entries from @a
   [the map part]

Note: @a is used in scalar context both times, meaning the number of entries 
in @a.

perldoc -f map
perldoc -f join
perldoc -f rand


My tip for cases where you get a working solution you don't understand fully:
a) Try to find out what "belongs together" (imagine '()'s)
b) Try to break the solution apart according to the findings in a)
c) examine the parts: print them out, dump them with Data::Dumper, modify
   them, read the man pages
d) put them together again, eventually one by one part, using examination 
   techniques as in c)


Hope this helps!

Dani


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to