"Lawrence, Rob" wrote:
> 
> This is sad....
> 
> How do you check to see if a string is empty?
> 
> my $stuff
> while($stuff "I don't know)
> {
> print "You must enter a value\n";
> $stuff = <STDIN>;
> }

There's defined and there's empty.  You can check for either or both.

my $stuff;
if ($stuff) {
        print "stuff was undefined/empty 1\n";
}
if ($stuff eq '') {             # error if undefined
        print "stuff was empty 2\n";
}
if (not length $stuff) {        # error if undefined
        print "stuff was empty 3\n";
}
if (not defined $stuff) {
        print "stuff was undefined 4\n";
}

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   http://www.wgn.net/~dbe/
  / ) /--<  o // //      Mailto:[EMAIL PROTECTED]   http://dbecoll.webjump.com/
-/-' /___/_<_</_</_    http://www.freeyellow.com/members/dbecoll/
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to