You bet! I glossed over that in the code example in this article because I wanted the code to be as clear as possible for non-Perl folks. I'm hoping that people who are interested in the Perl aspect will take the time to look at the demo. It uses exists() instead of defined() when testing against the table for just that reason. In the demo I also wanted to avoid dependancies. But at some point I would like to circle back and explore if the lookup table can be made read-only after it is built, which would be better still. I just need to take the time to explore modules like ReadonlyX.
ReadonlyX is a great option for this. Note that exists and defined both still autovivify any intermediate structures - e.g. if you are looking at $foo->{bar}{baz} then $foo will be autovivified to {bar => {}} regardless of what the end check is (the final element will not be vivified unless assigned to). Two options for avoiding this are autovivification and my Data::DeepAccess.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Watch out for autovivication.
You bet! I glossed over that in the code example in this article because I wanted the code to be as clear as possible for non-Perl folks. I'm hoping that people who are interested in the Perl aspect will take the time to look at the demo. It uses exists() instead of defined() when testing against the table for just that reason. In the demo I also wanted to avoid dependancies. But at some point I would like to circle back and explore if the lookup table can be made read-only after it is built, which would be better still. I just need to take the time to explore modules like ReadonlyX.
ReadonlyX is a great option for this. Note that exists and defined both still autovivify any intermediate structures - e.g. if you are looking at
$foo->{bar}{baz}
then$foo
will be autovivified to{bar => {}}
regardless of what the end check is (the final element will not be vivified unless assigned to). Two options for avoiding this are autovivification and my Data::DeepAccess.