troyhughes has asked for the wisdom of the Perl Monks concerning the following question:
Hi there. I am attempting to test a script that worked without error on my windows box to a Red Hat Linux distro. I get the error 'Use of uninitialized value in pattern match (m//)' on the first line of the if statement from the function below. I've found examples of this error online but fail to see how they apply to my situation. How can I fix this error? Thanks.
sub isUndefOrWhitespace { my $str = ''; $str = shift; print "$str\n"; if (!defined $str) { return 0; }elsif (/^\s*$/) { return 0; } return 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use of uninitialized value in pattern match (m//)
by AnomalousMonk (Archbishop) on May 23, 2012 at 22:37 UTC | |
|
Re: Use of uninitialized value in pattern match (m//)
by tobyink (Canon) on May 23, 2012 at 22:38 UTC | |
|
Re: Use of uninitialized value in pattern match (m//)
by sauoq (Abbot) on May 23, 2012 at 22:39 UTC | |
by Sushma (Initiate) on Nov 09, 2012 at 09:47 UTC | |
by Corion (Patriarch) on Nov 09, 2012 at 09:53 UTC |