On Apr 28, 2012, Lesley Binks wrote:

> To be robust, you might need to check that $xtra is defined AND has something
> sensible in it using a regexp.


        Well, after being set straight to the error of my ways, I finally have 
code that seems to work in any situation:

my $mail_field;   # set from a config file
$mail_field =~ s/\s+//g;
my $host = 'localhost';

if ( defined ($mail_field) and ($mail_field ne '') ) {
        $host = $mail_field;
}

        This works no matter what gets entered. **

Thanks everyone,
Marc


** examples tested:

$mail_field;
$mail_field = '';
$mail_field = '  ';
$mail_field = 'mail.example.com';
$mail_field = ' mail.example.com ';


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to