in reply to Object property not legal as direct object?
From perldoc print:
If you're storing handles in an array or hash, or in general whenever you're using any expression more complex than a bareword handle or a plain, unsubscripted scalar variable to retrieve it, you will have to use a block returning the filehandle value instead
So, this works fine:
#!/usr/bin/env perl use strict; use warnings; my $hr = { logfh => \*STDOUT }; print { $hr->{'logfh'} } "Hello Hashref\n"; my $obj = bless ($hr, 'UNIVERSAL'); print { $obj->{'logfh'} } "Hello Object\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Object property not legal as direct object?
by Daniel Beardsmore (Initiate) on Nov 09, 2016 at 11:46 UTC | |
|
Re^2: Object property not legal as direct object?
by BillKSmith (Monsignor) on Nov 09, 2016 at 20:51 UTC |