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

Re: Problem with unless statement

Thread Previous | Thread Next
From:
Jim Gibson
Date:
April 28, 2012 09:10
Subject:
Re: Problem with unless statement
Message ID:
F9EFD68F-ABAA-4AB5-9585-E9715B603403@gmail.com

On Apr 28, 2012, at 9:04 AM, sono-io@fannullone.us wrote:

> my $host = 'localhost';
> 
> if ( defined ($mail_field) and ($mail_field ne '') ) {
> 	$host = $mail_field;
> }

I would use:

my $host = $mail_field ? $mail_field : 'localhost' ;


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