Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: Convert string to hash

by gabrielsousa (Sexton)
on Mar 27, 2017 at 18:15 UTC ( #1186116=note: print w/replies, xml ) Need Help??

in reply to Re: Convert string to hash
in thread Convert string to hash

just added the'\' and worked :)
foreach my $value (values $jsonhash{results} ) { $temp{$value->{'certname'}} = \%$value; }

Replies are listed 'Best First'.
Re^3: Convert string to hash
by AppleFritter (Vicar) on Mar 27, 2017 at 18:22 UTC

    That works, but it is unnecessary, since \ and % are complements, in a sense, and cancel each other out: % dereferences a hash reference ($value), i.e. gives you the hash it references; \ then gives you a reference to this hash again.

    There's nothing wrong with doing it this way, but I encourage you to get a good grip on references (hash or not). You'll often encounter them in Perl, and nested data structures don't work without them at all.

Re^3: Convert string to hash
by 1nickt (Abbot) on Mar 27, 2017 at 18:21 UTC

    It's cheaper to throw away a % than to add a \ ...

    Your solution is silly. Read perlreftut to find out why ... worth your time!

    The way forward always starts with a minimal test.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1186116]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2021-09-28 16:51 GMT
Find Nodes?
    Voting Booth?

    No recent polls found