This is a bit of a hard one to explain succinctly!
Given an object built on a hash reference:
my $self = bless( { log => undef, }, $package );
Perl won't allow you to use this!
You can't write this:
say $self->{'log'} 'Message';This results in: String found where operator expected at ..., near "} ''" (Missing operator before ''?)
Having converted this module from package globals to OOP, I started getting bizarre crashes: "Not a CODE reference"
This, I tracked down to:
say $self->{'log'} ($detailedMessage // $message);Here, having an object property as a direct object file handle causes Perl to defecate building materials.
It doesn't seem to be a common thing to want to do, as I'm not seeing any suggestion that anyone else is seeing this fail.
It's not a huge deal to have to copy the file handle reference into a local variable to use it with say, but it's just very odd and it would be nice to understand what it's tripping up over here.
This is perl 5, version 20, subversion 2 (v5.20.2) built for x86_64-linux-gnu-thread-multi. The code begins:
use strict; use warnings; use utf8; use 5.10.0; no warnings 'experimental::smartmatch';
In reply to Object property not legal as direct object? by Daniel Beardsmore
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |