Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ternary operator assignment in Perl module

Status
Not open for further replies.

gnubie

Programmer
Apr 16, 2002
103
US
I have a perl module with a ternary assignment. $domain is exported.

Code:
$domain = $^O eq "Win32"?"localhost":"www.mydomain.net";

$domain should be getting localhost, but is getting www.mydomain.com.

Are ternary assignments supposed to work in perl modules (used or required)?

GN
 
sure, the ternary operator works in perl, I suspect your first condition is not written properly:

$^O eq "Win32"

have you tired:

$^O eq 'MSWin32'

you should really use single quotes around strings with no variable interpolation in perl but it will work with double-quotes:

$domain = $^O eq 'MSWin32' ? 'localhost' : '
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top