$self->[UTF8] = $conf->{utf8};
Never seen such code before.
What does []
mean here?
In this case, the object $self
is implemented as a blessed array reference rather than the far more common method of using a blessed hash reference. The syntax $foo->[42]
accesses a single element from an array reference. Presumably, UTF8
is a constant that returns a numeric index into the array.
You see this idiom sometimes when people become convinced (usually incorrectly) that hash lookups on object attributes result in significant overhead and try to prematurely optimize their code.
The []
implies that $self
is a reference to a list/array (assuming the code works). This looks a bit odd, though, as list indexes should be numeric.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With