An alternate version:

my $value = ( $t1lsq{$interfaceName} >= 4) ? 4 : $t1lsq{$interfaceName};

and a test:

$ perl -le '
$t1lsq{$interfaceName}=2 ;
my $value = ( $t1lsq{$interfaceName} >= 4) ? 4 : $t1lsq{$interfaceName};
print $value
'
2

$ perl -le '
$t1lsq{$interfaceName}=5 ;
my $value = ( $t1lsq{$interfaceName} >= 4) ? 4 : $t1lsq{$interfaceName};
print $value
'
4

Regards,
- Robert

On Fri, Aug 22, 2008 at 12:05 AM, Raymond Wan <[EMAIL PROTECTED]> wrote:
>
> Hi Noah,
>
> The ?: operator would do the trick:
>  http://www.perl.com/doc/manual/html/pod/perlop.html#Conditional_Operator
>
> I think what you need would be this, but I haven't tried it:
>
> (my $value > 4) ? ($value = 4) : ($value = $t1lsq{$interfaceName});
>
> Ray
>
>
>
> Noah wrote:
>>
>> Hi there,
>>
>> Is there a way to simplify the following to one line?
>>
>>
>> ---
>>
>>                my $value = $t1lsq{$interfaceName};
>>                $value = 4 if $value > 4;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to