in reply to Re: dereferencing ... again
in thread dereferencing ... again

hi, Sorry, my programming fu is too limited so I cannot answer your question. This is a part of the VMware API, so it is accessible. I got it to work assigning it like this:
foreach (@$add_info) { if ( $_->identifierType->key eq "ServiceTag" ) { my $test = $_->identifierValue; print $test, "\n" ; } }
I dit try printing
print $_->{identifierValue}, "\n";
And got this error:
HostSystemIdentificationInfo=HASH(0xaf5bd70)->identifierValue
But if I assign that to a variable, it works. O well.

Update: your suggestion works, I missed the curly braces (blush), so I can skip one step (no need to assign anything).

Thanks! I have no points to give today, will give tomorrow

Replies are listed 'Best First'.
Re^3: dereferencing ... again
by davido (Cardinal) on Nov 01, 2013 at 22:33 UTC

    So "identifierValue()" is an attribute accessor for your object. Using $_->{identifierValue} is a kludgy hack, which I proposed in the absence of more information about the object's interface. Now that we know that $_->identifierValue works, where $_->_identifierValue didn't, you can do away with my fragile hack.

    print $_->identifierValue(), "\n";

    ...should work just fine. The reason that we don't want to use $_->{identifierValue} if we can help it is because it's probably not part of the public interface for the object. The author of the class could change its internal implementation and break your code, because you're mucking with the object's internals. I assume that identifierValue() is part of its public interface, and is less likely to change without warning.


    Dave