On Sat, Apr 28, 2012 at 07:16:18AM -0700, sono...@fannullone.us wrote:
>       I'm having a problem with the following code:
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my $xtra = 'mail.example.com';
> 
> my $host = 'localhost' unless (defined ($xtra));
> 
> print $host;
> 
>       I get the message "Use of uninitialized value $host in print".  Does 
> anyone know why this doesn't work?
> 
Hi Marc

> my $host = 'localhost' unless (defined ($xtra));

Says the $host identifier will be assigned the value 'localhost' only if $extra
is not defined. 

But $extra is defined as 'mail.example.com' so $host won't be.

Thus you get the appropriate warning message.

Regards

Lesley

-- 
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