develooper Front page | perl.bugmongers | Postings from September 2004

Re: Odd sort() problem

From:
Islaw R.
Date:
September 29, 2004 13:45
Subject:
Re: Odd sort() problem
Message ID:
20040929193139.22345.qmail@lists.develooper.com
Paul Lalli wrote:
> "187" <bigal187@invalid.rx.eastcoasttfc.com> wrote in message
> news:2s0bj9F1f8ihqU1@uni-berlin.de...
>> A. Sinan Unur wrote:
>>> "187" <bigal187@invalid.rx.eastcoasttfc.com> wrote in
>>> news:2s07v9F1fvtn5U1 @uni-berlin.de:
>>>
>>>>    C:\> perl -e "print qq{\n}, join(qq{\n}, sort { lc{$a} cmp
>>>>            lc($b) } split(/;/, $ENV {'PATH'})), qq{\n};"
>>>
>>> I like one liners but I avoid them precisely for this type of
>>> problem: lc{$a} should be lc($a) or just lc $a.
>>
>> But what I really don't understand is why it doesn't result in a
>> compile error? lc{$a}, one would think, is not a valid statement.
>
> The warning below answers this question.
>
>> I admit should I have used -w in there:
>>
>>    Odd number of elements in anonymous hash at -e line 1.
>>    Odd number of elements in anonymous hash at -e line 1.
>>    Odd number of elements in anonymous hash at -e line 1.
>>    [......]
>>
>
> You're passing to the lc() function an anonymous hash.  That anonymous
> hash is poorly constructed, containing an odd number of elements.  So
> it is not invalid syntax, it's just not at all what you meant.
>
> Paul Lalli



-- 
187





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About