clintonm9 has asked for the wisdom of the Perl Monks concerning the following question:

I have a blessed object in perl. When i use data dumper i get something like this:
print Dumper $returnHash->{'Status'}; $VAR1 = bless( do{\(my $o = 62)}, 'FedexRateServiceTypes::Notification +SeverityType' );
if i just print this i get the following
print $returnHash->{'Status'}; Hello World
Is there anyway to copy just the string text to a new scalar and not the bless?

Replies are listed 'Best First'.
Re: Perl blessed object to scalar
by ikegami (Patriarch) on Mar 28, 2011 at 04:05 UTC
    The objects appears to overload stringification. Although there is rarely the need to do so, one can force stringification as follows:
    my $status_str = "$returnHash->{Status}";
    my $status_str = ''.$returnHash->{'Status'};

    It may have also have a method to do stringification.

    my $status_str = $returnHash->{'Status'}->as_string();

    The name of the method, if any, is dependent on the implementation of the class.

      wow that was an easy fix! Thank you very much!