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

Problem with unless statement

Thread Next
From:
sono-io
Date:
April 28, 2012 07:16
Subject:
Problem with unless statement
Message ID:
5CF59E24-362F-4102-896C-E71552E2CE51@fannullone.us
	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
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