Dave's Brain

Browse - Programming Tips - How can I check a string for all whitespace or not in Perl?

Date: 2016dec15
Language: perl

Q.  How can I check a string for all whitespace or not in Perl?

A.

sub isSpace($) { return $_[0] =~ m/^\s*$/; } sub hasContent($) { return ! isSpace($_[0]); }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.