Just to see if this could be done :)
NOTE: I faked the rest of your object since yours was incomplete :(
#!/usr/bin/perl -l # https://perlmonks.org/?node_id=1229668 use strict; use warnings; my $CustomField = bless { foo => 1, values => bless({ maxvalues => 1, name => 'Case type', }, 'ClassOne'), bar => 2, }, 'ClassTwo'; use Data::Dumper; print Dumper $CustomField; print '$CustomField->Values->Name = ', $CustomField->Values->Name; ######################## just add this ( hehehe :) sub UNIVERSAL::AUTOLOAD { my $basename = (split /::/, $UNIVERSAL::AUTOLOAD)[-1]; $basename eq 'DESTROY' and return; my ($realname) = grep lc $basename eq lc, keys %{ $_[0] }; defined $realname or die "Missing the key '$basename'"; return $_[0]{$realname}; }
Outputs:
$VAR1 = bless( { 'values' => bless( { 'name' => 'Case type', 'maxvalues' => 1 }, 'ClassOne' ), 'bar' => 2, 'foo' => 1 }, 'ClassTwo' ); $CustomField->Values->Name = Case type
In reply to Re: Get value from object
by tybalt89
in thread Get value from object
by danny20085
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |