|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
PERL: how to tell if variable is NULL
How to I do a check on a variable to see if it's null-- I am using Perl.
|
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
Code:
if ($str eq '') {
<some commands>
} |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Works like a charm...thanks.
|
|
#4
|
||||
|
||||
|
The function "defined" may also achieve what you require; check the usual perldoc for details.
![]() |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Oh that's pretty cool - I don't really like $str eq '' anyway.. i like a more concrete test like isnull(xxx) or something where you can look at it and right away you know what it's testing for. Code:
my ($some);
$some = "";
if (defined($some)) {
print "defined";
} else {
print "not defined";
}If you remove [$some = "";] you'll see "not defined" instead of "defined". |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to check null variable | sachin.gangadha | Shell Programming and Scripting | 2 | 12-06-2007 03:59 PM |
| not null cheking of an argument in perl | ammu | Shell Programming and Scripting | 4 | 06-05-2007 09:58 AM |
| test Null variable | kykyboss | Shell Programming and Scripting | 1 | 11-24-2006 11:02 AM |
| check for NULL variable | esham | Shell Programming and Scripting | 2 | 03-20-2005 02:31 AM |
| How to filter a null variable. | gio123bg | Shell Programming and Scripting | 1 | 12-19-2003 09:54 AM |
|
|