redtux has asked for the wisdom of the Perl Monks concerning the following question:
This gives initialized warnings on the last two lines if the value is blank. However I cant seem to get the problems lines to check. The defined check at the top prints everything that is either blank or 0. However 0 is a fully valid value, not undef. If I test for true (if ($hash{$file}->{$opt}){}), everything with a zero gets removed. Is there any way around this? (I'm probably missing something basic here) thanks Mikeforeach my $file (keys %hash){ foreach my $opt (keys %{$hash{$file}}){ if (!(defined $opt,$hash{$file}->{$opt})){ say '9809 ', join '|',$file,$opt,$hash{$file}->{$opt}; } $hash{$file}->{$opt}=~s/[^[:ascii:]]//gxms; my $lined=join ("\t",$file,$opt,$hash{$file}->{$opt})."\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: defined and value is 0
by Athanasius (Archbishop) on Jul 06, 2020 at 14:14 UTC | |
by redtux (Sexton) on Jul 06, 2020 at 15:37 UTC | |
|
Re: defined and value is 0
by hippo (Archbishop) on Jul 06, 2020 at 12:56 UTC | |
|
Re: defined and value is 0
by BillKSmith (Monsignor) on Jul 06, 2020 at 14:58 UTC |