ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:
my $date = $ARGV[0]; $date or $date = `date --date='1 hour ago' +%Y-%m-%d`; chomp $date;
In this code if the "$date" is NULL then its taking the system date.
But in this code if the hash element is NULL I need to write '0'. For that I tried this way
foreach my $sub_user_error (@db_user_errors) { $worksheet->write( $row, $col, $db_error_data{$hour}{'Submissio +n_user_error'}{$sub_user_error} or 0, $number); $col++; } $row++;
But its not working. Later I tried like
foreach my $sub_user_error (@db_user_errors) { if ($db_error_data{$hour}{'Submission_user_error'}{$sub_user_erro +r} eq "") { $worksheet->write( $row, $col, 0, $number); $col++; } else { $worksheet->write( $row, $col, $db_error_data{$hour}{'Submiss +ion_user_error'}{$sub_user_error}, $number); $col++; } } $row++;
Its working but seems too ugly. Is there any better way for doing this.
Thanks in Advance for helping
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with Excel::Writer::XLSX in using 'or'
by marioroy (Prior) on May 03, 2016 at 04:00 UTC | |
|
Re: Need help with Excel::Writer::XLSX in using 'or'
by Athanasius (Archbishop) on May 03, 2016 at 12:40 UTC | |
by marioroy (Prior) on May 03, 2016 at 13:30 UTC |