Re: Odd sort() problem
From: Paul Lalli (mritty_at_gmail.com)
Date: 09/29/04
- Next message: Paul Lalli: "Re: Syntax appears inconsistent - why is this?"
- Previous message: KVN Chary: "Trailing Spaces -- Format Perl"
- Next in thread: John W. Krahn: "Re: Odd sort() problem"
- Maybe reply: John W. Krahn: "Re: Odd sort() problem"
- Reply: Sid Norman: "Re: Odd sort() problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Sep 2004 20:19:43 GMT
"187" <bigal187@invalid.rx.eastcoasttfc.com> wrote
> Paul Lalli wrote:
> > "187" <bigal187@invalid.rx.eastcoasttfc.com> wrote
> >> A. Sinan Unur wrote:
> >>> "187" <bigal187@invalid.rx.eastcoasttfc.com> wrote
> >>
> >> 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.
>
> But shouldn't it be complaining either that lc{ } is an undefined hash
> or lc being a bareword?
Of course not. lc is a built in function. it's taking whatever comes
after "lc" as the parameter you're passing to lc. In this case, what
follows is an anonymous hash, signified by the { }
> Even if I add 'use strict;' before the print statement (or -Mstrict).
>
> >
> > 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.
>
> But should it not interpret lc{} as a bareword hash, and therefore
issue
> an error about bareword? I'm askign in case this is actually a bug.
No. It's not a bug. It's a problem with your belief that { } are used
only to get at an elment of an existing hash. What you did was
equivalent to this:
$ref = {$a}; #assign a poorly-constructed hashref to $ref;
lc $ref; #pass that hash reference as a parameter to the lc function.
Paul Lalli
- Next message: Paul Lalli: "Re: Syntax appears inconsistent - why is this?"
- Previous message: KVN Chary: "Trailing Spaces -- Format Perl"
- Next in thread: John W. Krahn: "Re: Odd sort() problem"
- Maybe reply: John W. Krahn: "Re: Odd sort() problem"
- Reply: Sid Norman: "Re: Odd sort() problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|