perl - Data::Dumper returned hash with a slash -


so have line of perl code reads this:

my $stored_value = $foo->some_function($argument); 

when dumper on it:

warn dumper $stored_value 

i receive result.

$var1 = \{              'foo' => 'abc',              'bar' => '123' }; 

now, i've seen results this:

warn dumper $another_hash; $var1 = {       'foo' => 'bar',       'baz' => 'quux'     }; 

and if wanted say, foo's value, i'd type in this:

warn dumper $another_hash->{'foo'}; 

to result.

$var1 = 'bar'; 

originally, couldn't find through google searches, now, made little test script play around saw, , found out

#!/usr/bin/perl # use strict; use warnings; use data::dumper;  sub test { $brother = {'ted'}; $brother->{'ted'} = 'brother'; return \$brother; }  $blah= test(); $blah = ${$blah}; print dumper $blah->{'ted'}; print "\n"; 

here results:

$var1 = 'brother'; 

i wanted share had found incase else ran same thing, did see?

i saw how in http://perldoc.perl.org/perlref.html#using-references, wanted clarification on it.

i'm not sure question is, output shows $stored_value reference scalar, which, in turn, reference hash.

it useful keep references scalars may indicate bug.

this short program shows how value have been created

use strict; use warnings;  use data::dumper;  $href = {   foo => 'abc',   bar => '123', };  $href_ref = \$href;  print dumper $href_ref; 

output

$var1 = \{             'bar' => '123',             'foo' => 'abc'           }; 

and, way, more useful use data::dump in preference data::dumper


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -