Hash parsing considered ugly

Jonathan McKeown jonathan at hst.org.za
Sun Feb 26 20:00:45 GMT 2006


On Sunday 26 February 2006 00:27, drkjam wrote:

>     my %h = (
>         foo => 1,
>         foo => 2,

[leads to %h being ( foo => 2 )]
> Is there any way at all to get Perl to flag this with at least some form
> of warning?

Why? Consider:

sub blah {
    my %defaults = ( foo => 17, bar => 23, baz => 42 );
    my %args = ( %defaults, @_ );
   ......
}

.... and later ....

blah( bar => 666 );

Do you really want a warning generated because you've provided a non-default 
value for one of blah()'s arguments?

Jonathan


More information about the london.pm mailing list