in reply to How to detect non printable characters and non white space characters? [RESOLVED]
# If not white space character AND not non printable character remove +element
That's probably because there are too many negations. If you have an if with else , using negation in the condition makes it really hard to understand. So, instead of
if ($$hoh_ref{$key}{$value} !~ /[^[:print:]]/g && $$hoh_ref{$key}{$value} !~ /\s/) { delete $$hoh_ref{$key}{$value}; } elsif ($$hoh_ref{$key}{$value} =~ /[^[:print:]]/g) { while ($$hoh_ref{$key}{$value} =~ /[^[:print:]]/g) { print "Non Printable Characater:\t$&\n"; } }
you can use a bit simpler
if ($$hoh_ref{$key}{$value} =~ /[^[:print:]]/) { # no /g neede +d while ($$hoh_ref{$key}{$value} =~ /[^[:print:]]/g) { print "Non Printable Characater:\t$&\n"; } } elsif ($$hoh_ref{$key}{$value} !~ /\s/) { delete $$hoh_ref{$key}{$value}; }
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to detect non printable characters and non white space characters?
by thanos1983 (Parson) on Feb 17, 2017 at 11:03 UTC | |
by Marshall (Canon) on Feb 17, 2017 at 12:28 UTC |