develooper Front page | perl.beginners | Postings from April 2012

Re: Problem with unless statement

Thread Previous | Thread Next
From:
Lawrence Statton
Date:
April 28, 2012 07:25
Subject:
Re: Problem with unless statement
Message ID:
4F9BFDD7.4090909@cluon.com
On 04/28/2012 09:16 AM, sono-io@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?
>
> Thanks,
> Marc

Greetings.

It doesn't work, because $host is uninitialized.  What did you expect it 
to be?



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About