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