On Fri, Nov 28, 2008 at 22:21, John W. Krahn <[EMAIL PROTECTED]> wrote:
> Chas. Owens wrote:
>>
>> On Fri, Nov 28, 2008 at 10:28, John W. Krahn <[EMAIL PROTECTED]> wrote:
>> snip
>>>
>>> perl -le'@chars = 33 .. 126; print map chr $chars[ rand @chars ], 1 .. 8'
>>
>> snip
>>
>> Perl Golf time:
>>
>> perl -le'print map chr+(33..126)[rand 94],1..8'
>
> $ perl -le'print map chr+(33..126)[rand 94],1..8'
> Warning: Use of "chr" without parentheses is ambiguous at -e line 1.

Yeah, I found it odd that it threw that warning without warnings
turned on, but it still works; I wonder if that is a bug.  Adding the
parenthesis (and dropping the + since it is no longer needed to
prevent (33..126) from looking like the arguments to chr) only adds
one more character:

perl -le'print map chr((33..126)[rand 94]),1..8'

Also, the more confusing variant:

perl -le'print+map+chr((33..126)[rand 94]),1..8'

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

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


Reply via email to