http://qs1969.pair.com?node_id=7632


in reply to Return?

You may also think about using a different technique than just testing for carriage returns; it sounds like you'd like to use the default variable basically if the user didn't post any "good text" in the text box. So if they just posted whitespace (whether that be tabs, spaces, or carriage returns), you'd like to use the default variable.

In that case, use something like this:

$variable = "Some Default Messsage" unless $variable =~ /\S/;
This sets variable to the default unless it contains a non-whitespace character.