Sami_R has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
Preparing a hash, based on a condition need to set hash values to '-', is there any simplest way of implementing this, please.
For example: have only two values for day 1 and 4. And don't have values for day 2 and 3 so need to set '-'.
HASH NOW: =====> $VAR1 = { 'day' => 1, 'Balance' => '183.57', 'payment' => 0, 'Total' => 0, }; HASH NOW: =====> $VAR1 = { 'day' => 4, 'Balance' => '12.86', 'payment' => 0, 'Total' => 0, };
Expected output:
HASH NOW: =====> $VAR1 = { 'day' => 1, 'Balance' => '183.57', 'payment' => 0, 'Total' => 0, }; HASH NOW: =====> $VAR1 = { 'day' => 2, 'Balance' => '-', 'payment' => '-', 'Total' => '-', }; HASH NOW: =====> $VAR1 = { 'day' => 3, 'Balance' => '-', 'payment' => '-', 'Total' => '-', }; HASH NOW: =====> $VAR1 = { 'day' => 4, 'Balance' => '12.86', 'payment' => 0, 'Total' => 0, };
Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to set hash values to '-' .
by dsheroh (Monsignor) on Jun 14, 2020 at 11:04 UTC | |
|
Re: How to set hash values to '-' .
by tybalt89 (Monsignor) on Jun 14, 2020 at 21:42 UTC | |
|
Re: How to set hash values to '-' . (updated)
by AnomalousMonk (Archbishop) on Jun 14, 2020 at 10:36 UTC | |
|
Re: How to set hash values to '-' .
by kcott (Archbishop) on Jun 14, 2020 at 21:11 UTC | |
|
Re: How to set hash values to '-' .
by Marshall (Canon) on Jun 14, 2020 at 23:58 UTC |