#!/usr/bin/perl -w use strict; my $major_length = 8552; my $val = 4; # this gives $result as 33, as expected .... my $result = ($major_length == 4800) ? 18 : ($major_length == 8552) ? 33 : 0; # this gives $result as 1, not 33. Makes sense, # since $val == 4 evaluates to 1. But, I want $result to # be assigned 33, based on the fact that $val == 4. $result = ($major_length == 4800) ? 18 : ($major_length == 8552) ? ($val == 4) : 33; # this is what I had originally; it gives $result as 1, # not 33. $result = ($major_length == 4800) ? 18 : ($major_length == 8552) ? ($val == 4) : 33 ? ($val == 1) : 18; # Putting in parens doesn't help either # this gives $result as 1 - but # I want it to equal 18 or 33... $result = ($major_length == 4800) ? 18 : ( ($major_length == 8552) ? ($val == 4) : ( 33 ? ($val == 1) : 18 ) ); print "$result\n";