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

Re: Problem with unless statement

Thread Previous | Thread Next
From:
Shawn H Corey
Date:
April 28, 2012 07:54
Subject:
Re: Problem with unless statement
Message ID:
4F9C049D.40804@gmail.com
On 12-04-28 10: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));

# this is the same as saying:

my $xtra = 'mail.example.com';
my $host;
if( ! defined( $xtra )){
     $host = 'localhost';
}

# are you sure this is what you want?

>
> print $host;
>
> 	I get the message "Use of uninitialized value $host in print".  Does anyone know why this doesn't work?
>
> Thanks,
> Marc


-- 
Just my 0.00000002 million dollars worth,
   Shawn

Programming is as much about organization and communication
as it is about coding.

[updated for today's programmers]
"Show me your code and conceal your interfaces, and I shall continue
to be mystified. Show me your interfaces, and I won't usually need
your code; it'll be obvious."
	-- Fred Brooks

Don't be clever; being great is good enough.

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