Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How to set hash values to '-' .

by tybalt89 (Prior)
on Jun 14, 2020 at 21:42 UTC ( #11118063=note: print w/replies, xml ) Need Help??


in reply to How to set hash values to '-' .

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11118040 use warnings; my %hash = ( 1 => { Balance => 183.57, day => 1, payment => 0, Total => 0 }, 4 => { Balance => 12.86, day => 4, payment => 0, Total => 0 }, ); use Data::Dump 'dd'; dd \%hash; for my $day ( 1 .. 4 ) { $hash{$day} = { Balance => '-', day => $day, payment => '-', Total = +> '-' , %{ $hash{$day} // {} } }; } use Data::Dump 'dd'; dd \%hash;

Outputs:

{ 1 => { Balance => 183.57, day => 1, payment => 0, Total => 0 }, 4 => { Balance => 12.86, day => 4, payment => 0, Total => 0 }, } { 1 => { Balance => 183.57, day => 1, payment => 0, Total => 0 }, 2 => { Balance => "-", day => 2, payment => "-", Total => "-" }, 3 => { Balance => "-", day => 3, payment => "-", Total => "-" }, 4 => { Balance => 12.86, day => 4, payment => 0, Total => 0 }, }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2020-10-28 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (259 votes). Check out past polls.

    Notices?