diff options
author | Andinus <andinus@nand.sh> | 2020-06-10 18:00:08 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-06-10 18:00:08 +0530 |
commit | 23062e4c73a6584dbb72c393ce45fa7fdab4a1e1 (patch) | |
tree | 312dd870d7fae33d39c4671d22c12d473061bf1b | |
parent | d3924ce89f0d0ebf54fe7c40d70b22f028e780db (diff) | |
download | ara-23062e4c73a6584dbb72c393ce45fa7fdab4a1e1.tar.gz |
Use sprintf to append delta values
This does the same thing as the if block, I also applied it to all three values because "why not?". sprintf handles this cleanly.
-rwxr-xr-x | ara.pl | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/ara.pl b/ara.pl index cabb69f..d458ff4 100755 --- a/ara.pl +++ b/ara.pl @@ -186,14 +186,9 @@ foreach my $i ( 0 ... $rows_to_print - 1 ) { # Add delta only if it was updated Today. if ( $update_info eq "Today" ) { - if ( $statewise->[$i]{deltaconfirmed} >= 0 ) { - $confirmed .= " (+$statewise->[$i]{deltaconfirmed})"; - } else { - $confirmed .= " ($statewise->[$i]{deltaconfirmed})"; - } - - $recovered .= " (+$statewise->[$i]{deltarecovered})"; - $deaths .= " (+$statewise->[$i]{deltadeaths})"; + $confirmed .= sprintf " (%+d)", $statewise->[$i]{deltaconfirmed}; + $recovered .= sprintf " (%+d)", $statewise->[$i]{deltarecovered}; + $deaths .= sprintf " (%+d)", $statewise->[$i]{deltadeaths}; } $covid_19_data->addRow( |