Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!cti1!kmeek From: kmeek@cti1.UUCP (Kevin Meek) Newsgroups: comp.lang.perl Subject: Checking if a variable is null Keywords: perl null Message-ID: <483@cti1.UUCP> Date: 18 Apr 91 15:29:25 GMT Organization: Comprehensive Technologies Int., Arlington VA Lines: 28 Is there a perl equivalent to the shell test operators -z and -n I want to print a line if certain parts are not null. What I'm using is this: ($a,$b,$c) = split(' '); if ( $a ne '' && $b ne '' ) { print $_; } Is there a better way to check if a variable is null? i.e. print if -n $a Also I wanted to get it into a oneliner but when I have a multi part expression (i.e. EXPR && EXPR), I had trouble getting the print if EXPR construct to work. I always end up reverting back to C style if (EXPR) { BLOCK } construct. I'm just learning perl so feel free to set me straight if I don't make much sense. Kevin -- Kevin Meek kmeek@cti.com