Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Throw compilation error(or warning) if duplicate keys are present in hash

by rovf (Priest)
on Nov 24, 2011 at 10:02 UTC ( [id://939840]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Throw compilation error(or warning) if duplicate keys are present in hash
in thread Throw compilation error(or warning) if duplicate keys are present in hash

It is a manually generated .pm file by the people who are not very much familiar with perl syntax. Hence I suspect that there might be a good chance of mistyping an existing key.
You could get those people into assigning not to %hash, but to @hash, i.e. an array instead. Later in the program, you check @hash whether a "key" occurs twice, before assigning to %hash.

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^4: Throw compilation error(or warning) if duplicate keys are present in hash
by I_love_perl (Novice) on Nov 24, 2011 at 12:18 UTC

    Hi Ronald

    Yes. Absolutely we can write a piece of code to check for the existence of duplicate keys in a hash or array. But I felt like it should be present in some perl program check utilities (like use strict, use warnings).

    As I don't know if this facility is available in perl I posted this query to know if there some package(or pragma) available for this kind of checks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://939840]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-23 21:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found