Login | Register
My pages Projects Community openCollabNet

Discussions > users > Policy for hashref iteration without 'keys' keyword

perlcritic
Discussion topic

Back to topic list

Policy for hashref iteration without 'keys' keyword

Author aff
Full name Andreas Faafeng
Date 2011-12-22 05:44:56 PST
Message Hi Users,

I have discovered some instances where I have written

    foreach my $key (%{$var})

where I should have written

    foreach my $key (keys %{$var})

Both expressions are syntactically correct but functionally very different, and may lead to subtle bugs.

Is there a policy to catch this mistake (my search came up empty) ?

Best regards,
Andreas
--

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

Policy for hashref iteration without 'keys' keyword aff Andreas Faafeng 2011-12-22 05:44:56 PST
Messages per page: