Logo

Programming-Idioms

History of Idiom 110 > diff from v5 to v6

Edit summary for version 6 by :
[Perl] Missed "or contains whitespace" in original post

Version 5

2016-01-07, 19:40:14

Version 6

2016-01-07, 19:44:44

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Code
$blank = !$s;
Code
$blank = !$s;                 # true if undefined, or empty
$blank = !$s || $s=~/^\s*$/;  # ... or just whitespace